←back to thread

JSON Patch

(zuplo.com)
299 points DataOverload | 2 comments | | HN request time: 0.398s | source
Show context
bsimpson ◴[] No.41881312[source]
`/` is a weird choice of delimiter for JSON.

Since JSON is a subset of JS, I would have expected `.` to be the delimiter. That jives with how people think of JSON structures in code. (Python does require bracket syntax for traversing JSON, but even pandas uses dots when you generate a dataframe from JSON.)

When I see `/`, I think:

- "This spec must have been written by backend people," and

- "I wonder if there's some relative/absolute path ambiguity they're trying to solve by making all the paths URLs."

replies(9): >>41881377 #>>41881605 #>>41881615 #>>41882491 #>>41883303 #>>41883342 #>>41885101 #>>41885337 #>>41888089 #
bityard ◴[] No.41881605[source]
Maybe we're talking about different things, but resources in REST are identified by their URL and URLs use '/' to separate elements in the path.
replies(2): >>41881871 #>>41887373 #
bsimpson ◴[] No.41881871[source]
Yeah, but nobody ever looked at

    {
      "a": {
        "b": {
          "c": []
        }
      }
    }
and thought "I need the list at /a/b/c"
replies(3): >>41881910 #>>41881957 #>>41882009 #
1. bombela ◴[] No.41881957[source]
Anecdotal, I did and I do. It's no different than a path on a filesystem.
replies(1): >>41882617 #
2. stronglikedan ◴[] No.41882617[source]
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.