-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
add json path functionality to extract values #821
Comments
Hi @cdaller, I like this idea; I think it would be a great feature for the library. BTW, I think a signature like the following would offer greater flexibility: JsonVariant resolve(JsonVariant, const char* path); Regards, |
Another optimization: using a JsonPath object that does the parsing of the path only once, so mulitple extraction of the data of the same path will be more efficient. I think, this is a common behaviour - using the same path again and again. JsonPath parser should extract the key names and array indices, so resolving it to a value will become more efficient. Future parsers might support filter expressions or other features from http://goessner.net/articles/JsonPath/ - maybe we should have a look at https://github.com/danielaparker/jsoncons/blob/master/doc/ref/jsonpath/jsonpath.md // simple usage (not so efficient)
JsonVariant resolve(JsonVariant, const char* path);
// more efficient usage (optimize parsing)
JsonVariant resolve(JsonVariant, JsonPath); |
Hey @bblanchon has this feature been added since or not? |
Not exactly a JSON Path feature, but the function presented in #1505 (comment) can be used as a compile-time alternative. |
Please see #1904 (comment) for another basic implementation that support member access via |
I have an application that fetches a json file from an http server and extracts a value from the json. The url (and therefore the structure of the json) is configurable during runtime. So I wanted to use a json path to define which value to extract from the json content. I googled, but could not find any, so I wrote a very simple jsonPath parser.
I think a method like this would be quite useful in the library - what do you think?
As I am not very experienced in C++, the method could (and probably should) be rewritten before being integrated :-)
The text was updated successfully, but these errors were encountered: