3 ms·
> 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 ele
by culi 2y ago
> 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
- jabbany 2y agoQuery 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-jsonpath-00.html https://www.ietf.org/archive/id/draft-goessner-dispatch-json...
- numbsafari 2y agoYeah, 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 https://www.rfc-editor.org/info/rfc6902 [2] https://www.rfc-editor.org/info/rfc9535 https://www.rfc-editor.org/info/rfc9535 [3] https://www.rfc-editor.org/info/rfc6901 https://www.rfc-editor.org/info/rfc6901
- ccorcos 2y agoI also want to be able to insert into the array after an item as opposed to at a specific index. Biggest issue with JSON patch is its inability to handle even the simplest concurrent writes.