Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature wish: JSONPath #343

Closed
tesch1 opened this issue Oct 26, 2016 · 19 comments
Closed

feature wish: JSONPath #343

tesch1 opened this issue Oct 26, 2016 · 19 comments
Labels

Comments

@tesch1
Copy link

tesch1 commented Oct 26, 2016

A simple query() function would be a fantastic addition. Maybe it's totally out of scope for this project, but searching the issues didn't turn up any discussion, so maybe this issue is just a place to say it wont be done :)

Some related refs:
http://goessner.net/articles/JsonPath/
https://chromium.googlesource.com/external/mozc/+/master/src/net/jsonpath.cc
https://www.genivia.com/doc/xml-rpc-json/html/

@nlohmann
Copy link
Owner

Currently, only JSON Pointer is implemented. JSON Path sounds interesting, but I currently do not have the time to look into it.

@nlohmann
Copy link
Owner

nlohmann commented Nov 2, 2016

I had another look at this. It seems doable, but also a lot of work. I shall postpone this ticket until after the 3.0.0 release.

@tesch1
Copy link
Author

tesch1 commented Nov 2, 2016

No worries! It'd definitely a lot of work. Really cool of you to look at it tho, open source is awesome :)

@nlohmann
Copy link
Owner

nlohmann commented Jan 2, 2017

Is there an agreed upon reference for JSON Path?

@tesch1
Copy link
Author

tesch1 commented Jan 2, 2017

I think this is the first - http://goessner.net/articles/JsonPath/

@nlohmann
Copy link
Owner

nlohmann commented Jan 3, 2017

This less of a specification, but rather a list of examples.

Furthermore:

XPath has a lot more to offer (Location pathes in not abbreviated syntax, operators and functions) than listed here.

@nlohmann nlohmann added the state: help needed the issue needs help to proceed label Jan 3, 2017
@nlohmann
Copy link
Owner

I'm closing this for now in lieu of a proper specification of "JSONPath", see #343 (comment).

@yangbodong22011
Copy link

Hi, @nlohmann Would you consider supporting or accepting the PR of JSONPath?

@nlohmann
Copy link
Owner

Why not? Is there a proper specification now?

@yangbodong22011
Copy link

It is still not a standard, but we have "conventional" examples: https://github.com/freestrings/jsonpath/wiki/rust-examples

Including those implemented by RedisJSON.

@nlohmann
Copy link
Owner

I see. In any case, it would be best to implement this as free functions; that is, not to add any member functions, because the API is already pretty bloated. Do you think this is possible?

@yangbodong22011
Copy link

I haven't dig into the code details yet, and I don't quite understand what you mean by free functions.

But I think as a parsing path, under the premise that JSONPointer is already supported, it would be best if it can be automatically recognized as JSONPath or JSONPointer and successfully access the element.

@nlohmann
Copy link
Owner

I meant I'd rather have something like

json authors = json::selector(j, "$.store.book[*].author");

rather than

json authors = j.selector("$.store.book[*].author");

@yangbodong22011
Copy link

Oh, I think I agree with you, after all, json::parse is like this.

@yangbodong22011
Copy link

Why not? Is there a proper specification now?

FYI:
https://www.ietf.org/id/draft-ietf-jsonpath-base-03.html

@oiwg
Copy link

oiwg commented Sep 22, 2022

Now up to draft 6, progress tracked at https://datatracker.ietf.org/wg/jsonpath/about/ , standards track document due in November.

@jianbingfang
Copy link

Is the JsonPath feature available now?

@udem1234
Copy link

Hi.

@nlohmann : Any news on this ? :-)

(btw, I just came across this cool jsonpath online evaluator : JSONPath Online Evaluator by Kazuki Hamasaki for those who might be interested)

Thank you.

@nlohmann
Copy link
Owner

It's not on my todo list, but merge requests are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants