←back to thread

JSON Patch

(zuplo.com)
299 points DataOverload | 1 comments | | HN request time: 0.328s | source
Show context
culi ◴[] No.41880960[source]
> This pointer identifies the name field within the user object. You can refer to an array's entries by their index (ex. /user/friends/0 is Alice). The last element in an array ca be referenced using - (ex. /user/friends/- is John). If a property name contains ~, then inside the pointer it must be escaped using ~0, or if contains / then it must be escaped using ~1.

The biggest thing on my wishlist for a system like this is a standardized syntax for choosing an item in a list by an identifying (set?) of key-value pairs. E.g. for

  {
    "name": "Clark St Garden",
    "plants": [
      { "latin": "Phytelephas aequatorialis", year: 2009 },
      { "latin": "Ceiba speciosa", year: 2009 },
      { "latin": "Dillenia indica", year: 2021 }
    ]
  }
I'd like to be able to specify that I want to update Ceiba speciosa regardless of its index. This gets especially important if we're adding items or trying to analyze diffs of previous versions of a json item
replies(2): >>41881083 #>>41884326 #
jabbany ◴[] No.41881083[source]
Query by content reminds me of XPath, so I looked it up to see if there was a version for JSON...

Turns out there is https://www.ietf.org/archive/id/draft-goessner-dispatch-json...

replies(1): >>41881563 #
1. numbsafari ◴[] No.41881563[source]
Yeah, one option is to use a different content-type for your json-patch values and basically extend JSON Patch[1] to use JSON Path[2] instead of JSON Pointer[3].

[1] https://www.rfc-editor.org/info/rfc6902

[2] https://www.rfc-editor.org/info/rfc9535

[3] https://www.rfc-editor.org/info/rfc6901