5 ms·
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.
by bityard 2y ago
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.
- bsimpson 2y agoYeah, but nobody ever looked at { "a": { "b": { "c": [] } } } and thought "I need the list at /a/b/c"
- cjblomqvist 2y agoIf you've ever done XPath you do!
- magicalhippo 2y agoYeah, 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.
- bombela 2y agoAnecdotal, I did and I do. It's no different than a path on a filesystem.
- stronglikedan 2y agoBut 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.
- maxbond 2y agoSeems 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."
- bsimpson 2y agoYeah, 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.
- maxbond 2y agoOh I see what you mean. I misunderstood, I also don't like slash as a separator.
- diggan 2y ago> 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.
- inkyoto 2y agoIt 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.
- ddgflorida 2y agoWhen convertcsv.com converts JSON to CSV, it uses the / separator to store the structure in the column headings. Probably could use an option for . too.