
Bryce,
2011/1/2 Bryce Lelbach
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Currently there's one piece missing from my JSON parser in prana, the compiler that turns the utree ast into the JSON object that the user would access.
ATM the low level `parse_xxx(in, out)' interface for JSON is done, but this just produces a utree AST. The utree AST is useful for translating to other languages, or for applying generic utree algorithms to the JSON data, but it's not the ideal interface for less involved access. For that, we need a JSON specific data structure (as mentioned above) and compiler that can build said data structure from a utree AST.
OK. So, right now, nothing to acceess the parsed JSON structure. Am I right?
I've written most of the compiler (it's not lightning fast, but respectable for now, and it can be optimized later).
For my particular application, fast running code is not really a requirement.
If you're seriously interested in using Prana's JSON parser, perhaps you could help me come up with the syntax and semantics for the interface that would be exposed? How would you like to access that member? A few ideas, (not mutually exclusive):
std::ifstream ifs("foo.json", ifstream::in);
prana::json_object js;
prana::compile_json(ifs, js); // a number of types, such as a std::string, would // work for the first parameter.
std::cout << js["results"]["artworkUrl100"] << std::endl; // no range check std::cout << js.at("results").at("artworkUrl100") << std::endl; // if out of range, throws std::cout << js.find_first("artworkUrl100") << std::endl; // null if not found
Yes, I like this kind of STL-like access. What about the property_tree
interface:
std::cout << js.get
// uri stuff isn't integrated yet, but in a few days you'd also be able to do:
prana::uri_parts uri;
prana::parse_uri(js["results"]["artworkUrl100"], uri);
std::cout << uri.host << std::endl;
I'm hoping to finish up the JSON and URI stuff in the next day or so. I'd love to hear some suggestions :).
OK. I will thus, impatiently, wait for the next few days. Would love to help you, but as I really have no background with spirit, it is a little bit hard. Regards, Olivier
- -- Bryce Lelbach aka wash boost-spirit.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAk0gu24ACgkQO/fqqIuE2t5S6QCgma4zlA/wp7sy7A6db/IF7VCC 0EkAn12l5qL57yESwcTGQSTu6FPpYzGS =ept9 -----END PGP SIGNATURE----- _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users