News for hackers. Stuff that matters.
Re:Unlocking the Power of JSON Patch by bsimpson on Friday October 18, 2024 @01:58PM (#41881871)
Yeah, but nobody ever looked at

    {
      "a": {
        "b": {
          "c": []
        }
      }
    }
and thought "I need the list at /a/b/c"
Re:Unlocking the Power of JSON Patch by cjblomqvist on Friday October 18, 2024 @02:04PM (#41881910)
If you've ever done XPath you do!
Re:Unlocking the Power of JSON Patch by magicalhippo on Friday October 18, 2024 @02:45PM (#41882293)
Yeah, wrote my own XPath-like extension methods to manipulate JSON just like that. Felt very natural and makes it quite easy to generate and process JSON for the cases serialization/deserialization isn't the best option.
Re:Unlocking the Power of JSON Patch by maxbond on Friday October 18, 2024 @02:16PM (#41882009)
Seems like a reasonable thing to me.

    {
      "makes": {
        "toyota": {
          "models: [ ... ]
        }
      }
    }
"I need all the models of Toyota cars."

Or

"Toyota came out with a new Camry, I need to update the Camry object within Toyota's models."

Re:Unlocking the Power of JSON Patch by bsimpson on Friday October 18, 2024 @02:38PM (#41882225)
Yeah, but that's makes.toyota.models, not /makes/toyota/models.

The point is that this is a data structure and not a web server. It's using a convention from one domain in a different one. Relatively minor in the scope of possible quibbles, but it's just one more thing to remember/one more trivial mistake to make. I'm sure much collective time will be lost to many people using dots where the spec says to use slashes, and not realizing it because it looks right in every other context with dots. Dots also makes copy/pasting easier, because you wouldn't have to migrate the format after pasting.

Re:Unlocking the Power of JSON Patch by maxbond on Friday October 18, 2024 @02:45PM (#41882298)
Oh I see what you mean. I misunderstood, I also don't like slash as a separator.
Re:Unlocking the Power of JSON Patch by diggan on Saturday October 19, 2024 @06:22AM (#41886932)
> The point is that this is a data structure and not a web server.

URIs are not only used on web servers though, they're all over the place, probably most notable your filesystem is using `/` as a path separator, so it wouldn't be completely out of place to use it as a path separator elsewhere.

Re:Unlocking the Power of JSON Patch by inkyoto on Friday October 18, 2024 @07:10PM (#41884316)
It quickly gets convoluted since Camry has been produced for more than 30 years with regular model refreshes throughout the years, e.g. 1997, 2003, 2025 etc. JSON Pointer quickly falls short since we now require a selection expression to figure out which year model we need to update in the array of models: «makes.toyota.models[?year == `2025`]» (using JMESPath).

Both, JSONPath or JMESPath, support query expressions whereas JSON Pointer does not.

Re:Unlocking the Power of JSON Patch by bombela on Friday October 18, 2024 @02:09PM (#41881957)
Anecdotal, I did and I do. It's no different than a path on a filesystem.
Re:Unlocking the Power of JSON Patch by stronglikedan on Friday October 18, 2024 @03:25PM (#41882617)
But it's different than object notation in JS, and considering JSON stands for JavaScript Object Notation, I think dot notation would have been more appropriate for JSON Pointer (and by extension JSON Path). As a bit of a rebel myself, I use dot notation when describing a location in a JSON document, unless I'm forced to use the slash for something like JSON Pointer.