,---. Rogerz Zhang ( @ @ ) Human, not octopus ).-.( Chase what you love. Let the rest go. '/|||\` Share > Google+ | Note > Tumblr | Random > twitter 微博 '|` AsciiArt < Shimrod(hh)
To handle the problem of querying something inside a nested hierarchy, I
use a JSON array as the query string instead of Javascript-style
notation. So your example would become
json_get_object(json, "[\"store\", \"book\", 0, \"title\"]");
This way you can reuse the JSON parser for the query string, and your
implementation of the query function is really short and easy to read.
You just iterate over the array, getting the appropriate array element
or object property at each step, depending on whether you have a number
value or string value.
JKL
(2012年03月10日 04:27), rogerz wrote:
*. I want to get a json object reference by
json_get_object(json, "store.book[0].title");
To handle the problem of querying something inside a nested hierarchy, I use a JSON array as the query string instead of Javascript-style notation. So your example would become
json_get_object(json, "[\"store\", \"book\", 0, \"title\"]");
As far as I know, there are no JSONPath implementations for Jansson or
even the C language.
JSONPath is a bit problematic, as no accurate specification exists for
it. There's only a web page that explains one implementation and it
doesn't formally specify how identifiers should be parsed, for
example.
Petri
As far as I know, there are no JSONPath implementations for Jansson or
even the C language.
JSONPath is a bit problematic, as no accurate specification exists for
it. There's only a web page that explains one implementation and it
doesn't formally specify how identifiers should be parsed, for
example.
I have made a branch on jansson to implement the basic support for JSONPath. Please see my fork on GitHub for details:---rogerz
--
Jansson users mailing list
jansso...@googlegroups.com
http://groups.google.com/group/jansson-users