3 ms·
I'm a little surprised not to hear any mention of JSON Pointer (RFC 6901). It deals with exactly this: http://tools.ietf.org/html/rfc6901 http://tools.ietf.or
by drachel 12y ago
I'm a little surprised not to hear any mention of JSON Pointer (RFC 6901). It deals with exactly this:
http://tools.ietf.org/html/rfc6901 http://tools.ietf.org/html/rfc6901
With JSON Pointer syntax, it would be something like:
JWalk.getStringPtr(user, "/them/public_keys/primary/bundle");
It's concise, complete/unambiguous, and has implementations in a growing number of environments, so I think it could be worth mentioning as an approach. It also defines a useful URL fragment syntax for referencing nodes within documents, which would be a good thing for the JSON world.
- mpk 12y agoThat works very well combined with RFC 6902 - JSON-PATCH for partial changes to JSON objects, which in turn works nicely with HTTP PATCH method, RFC 5789.
- dochtman 12y agoI wrote a comment pointing to 6901, but it's probably still in moderation.
- tonyg 12y agoHis omission of RFC 6901 is especially remarkable considering he is listed by name in that RFC's acknowledgements section as having contributed to the specification!
- roberto 12y agoShameless plug: I wrote a small JSON database the supports JSON Pointer and JSON Patch: https://bitbucket.org/robertodealmeida/jsonstore https://bitbucket.org/robertodealmeida/jsonstore
- timbray 12y agoOh dear, I’ve probably hurt some feelings for having missed 6901. Interesting that when I googled around for JSON analogues of XPath, I didn’t turn that up. Having said that, it’s not obvious that any syntax is a win; an list of strings is an excellent selector that hits an 80/20 point & meets all my needs.