[OT] Interested in good (fast, robust) boost-based JSON API

Can anyone recommend one such good targeted library up to Boost's standards you've had good success with? (with a boost-like commercial friendly license) I guess it would need to be Tuple and Spirit based to be well integrated to Boost, although it could also have a polymorphic base json::value class too. Thanks for any insights. --DD PS: C++ JSON libraries listed at http://json.org/ don't seem quite up to the task, thus my post. PPS: If Spirit-based, a library using Spirit V2 as released in Boost 1.41 would be preferred.

Dominique Devienne wrote:
Can anyone recommend one such good targeted library up to Boost's standards you've had good success with? (with a boost-like commercial friendly license)
Boost.PropertyTree has some support for parsing and writing JSON, but it doesn't preserve types. Sebastian

On Tue, Dec 1, 2009 at 9:38 AM, Sebastian Redl <sebastian.redl@getdesigned.at> wrote:
Dominique Devienne wrote:
Can anyone recommend one such good targeted library up to Boost's standards you've had good success with? (with a boost-like commercial friendly license)
Boost.PropertyTree has some support for parsing and writing JSON, but it doesn't preserve types.
And even I whipped up a standards-compliant JSON parser in Boost.Spirit 2.1 in only two hours, would be easy to karma'ize it too to output (now that Spirit 2.1 is released with its interface no longer in flux, I really should finish that...)

On Tue, Dec 1, 2009 at 11:55 AM, OvermindDL1 <overminddl1@gmail.com> wrote:
On Tue, Dec 1, 2009 at 9:38 AM, Sebastian Redl <sebastian.redl@getdesigned.at> wrote:
Dominique Devienne wrote:
Can anyone recommend one such good targeted library up to Boost's standards you've had good success with? (with a boost-like commercial friendly license)
Boost.PropertyTree has some support for parsing and writing JSON, but it doesn't preserve types.
And even I whipped up a standards-compliant JSON parser in Boost.Spirit 2.1 in only two hours, would be easy to karma'ize it too to output (now that Spirit 2.1 is released with its interface no longer in flux, I really should finish that...)
Sounds good :) Would you mind sharing the grammar and parser in http://boost-spirit.com/repository/grammars/show_contents.php perhaps, with a Boost like license? Thanks, --DD

On Tue, Dec 1, 2009 at 12:44 PM, Dominique Devienne <ddevienne@gmail.com> wrote:
On Tue, Dec 1, 2009 at 11:55 AM, OvermindDL1 <overminddl1@gmail.com> wrote:
On Tue, Dec 1, 2009 at 9:38 AM, Sebastian Redl <sebastian.redl@getdesigned.at> wrote:
Dominique Devienne wrote:
Can anyone recommend one such good targeted library up to Boost's standards you've had good success with? (with a boost-like commercial friendly license)
Boost.PropertyTree has some support for parsing and writing JSON, but it doesn't preserve types.
And even I whipped up a standards-compliant JSON parser in Boost.Spirit 2.1 in only two hours, would be easy to karma'ize it too to output (now that Spirit 2.1 is released with its interface no longer in flux, I really should finish that...)
Sounds good :)
Would you mind sharing the grammar and parser in http://boost-spirit.com/repository/grammars/show_contents.php perhaps, with a Boost like license?
I did post the old version (that worked on a much older Spirit trunk, not the current release) on the Spirit list a long while ago. I meant to update it and give it a better interface and a karma output too then give it to Spirit as an example, I just need to get motivated to give the little amount of time that I have available, to it. ;-) (*hint* poke me to get it done, random emails, that helps a ton).

On Tue, Dec 1, 2009 at 4:42 PM, OvermindDL1 <overminddl1@gmail.com> wrote:
On Tue, Dec 1, 2009 at 12:44 PM, Dominique Devienne <ddevienne@gmail.com> wrote:
Would you mind sharing the grammar and parser in http://boost-spirit.com/repository/grammars/show_contents.php perhaps, with a Boost like license?
I did post the old version (that worked on a much older Spirit trunk, not the current release) on the Spirit list a long while ago. I meant to update it and give it a better interface and a karma output too then give it to Spirit as an example, I just need to get motivated to give the little amount of time that I have available, to it. ;-)
I'm still interested in just the Spirit 2.1 grammar for JSON if you don't mind, to implement just an event-based SAX-like parser for JSON. I'd happily use a full reading and writing impl, but I'd be happy with just the grammar for now.
(*hint* poke me to get it done, random emails, that helps a ton).
Consider yourself poked ;) Thanks, --DD

On Tue, Dec 1, 2009 at 4:03 PM, Dominique Devienne <ddevienne@gmail.com> wrote:
On Tue, Dec 1, 2009 at 4:42 PM, OvermindDL1 <overminddl1@gmail.com> wrote:
On Tue, Dec 1, 2009 at 12:44 PM, Dominique Devienne <ddevienne@gmail.com> wrote:
Would you mind sharing the grammar and parser in http://boost-spirit.com/repository/grammars/show_contents.php perhaps, with a Boost like license?
I did post the old version (that worked on a much older Spirit trunk, not the current release) on the Spirit list a long while ago. I meant to update it and give it a better interface and a karma output too then give it to Spirit as an example, I just need to get motivated to give the little amount of time that I have available, to it. ;-)
I'm still interested in just the Spirit 2.1 grammar for JSON if you don't mind, to implement just an event-based SAX-like parser for JSON. I'd happily use a full reading and writing impl, but I'd be happy with just the grammar for now.
(*hint* poke me to get it done, random emails, that helps a ton).
Consider yourself poked ;) Thanks, --DD
Ew... I really did make this back when I was still learning Spirit, I can make it better now for sure... Just to show you the simple grammar for JSON parsing though, I was trying to follow the Spec *to*the*letter*, and this is what I came up with (which I definitely need to redesign for the modern Spirit2.1). As stated, this is for the old trunk Spirit so it might not compile with the current version... struct JSON_grammar : qi::grammar<typename StringType::const_iterator, Value(), boost::spirit::ODL1_JSON_Char_Class::space_type> { JSON_grammar() : JSON_grammar::base_type(ValueRule) { using qi::on_error; using qi::fail; using qi::debug; using qi::lit; using qi::raw; using spirit::double_; using namespace boost::spirit::ODL1_JSON_Char_Class; ValueRule =( lit("null") [spirit::_val = null_const()] | lit("false") [spirit::_val = false_const()] | lit("true") [spirit::_val = true_const()] | double_ [spirit::_val = spirit::_1] | StringRule [spirit::_val = spirit::_1] | ArrayRule [spirit::_val = spirit::_1] | ObjectRule [spirit::_val = spirit::_1] ); StringRule = char_('"') [spirit::_val = ""] >> *( (char_-(char_("\"\\")|cntrl)) [spirit::_val += spirit::_1] |(lit('\\') >> (lit('b') [spirit::_val += '\b'] |lit('f') [spirit::_val += '\f'] |lit('n') [spirit::_val += '\n'] |lit('r') [spirit::_val += '\r'] |lit('t') [spirit::_val += '\t'] | ( lit('u') >> hex4 [spirit::_val += spirit::_1] ) |char_ [spirit::_val += spirit::_1] ) ) ) >> '"' ; ArrayRule %= '[' >> ValueRule % ',' >> ']' ; ObjectRule %= '{' >> (StringRule >> ':' >> ValueRule) % ',' >> '}' ; ValueRule.name("ValueRule"); StringRule.name("StringRule"); ArrayRule.name("ArrayRule"); ObjectRule.name("ObjectRule"); on_error<fail> ( ValueRule , onerror() ); #ifdef ODL1_JSON_DEBUG debug(ValueRule); debug(StringRule); debug(ArrayRule); debug(ObjectRule); #endif // ODL1_JSON_DEBUG } qi::rule<typename StringType::const_iterator, Value(), boost::spirit::ODL1_JSON_Char_Class::space_type> ValueRule; qi::rule<typename StringType::const_iterator, StringType()> StringRule; qi::rule<typename StringType::const_iterator, ValueArray(), boost::spirit::ODL1_JSON_Char_Class::space_type> ArrayRule; qi::rule<typename StringType::const_iterator, ValueObject(), boost::spirit::ODL1_JSON_Char_Class::space_type> ObjectRule; qi::uint_parser<unsigned, 16, 4, 4> hex4; }; Yuck, that really is ugly... That should show you how it works, but yeah, wait until I can actually redesign it. I do not have time right this moment (keep poking me and I may have this odd hour here or there), but should have some dedicated time late next week, just keep on poking/emailing me.

OvermindDL1 wrote:
On Tue, Dec 1, 2009 at 4:03 PM, Dominique Devienne <ddevienne@gmail.com> wrote:
On Tue, Dec 1, 2009 at 4:42 PM, OvermindDL1 <overminddl1@gmail.com> wrote:
On Tue, Dec 1, 2009 at 12:44 PM, Dominique Devienne <ddevienne@gmail.com> wrote:
Would you mind sharing the grammar and parser in http://boost-spirit.com/repository/grammars/show_contents.php perhaps, with a Boost like license? I did post the old version (that worked on a much older Spirit trunk, not the current release) on the Spirit list a long while ago. I meant to update it and give it a better interface and a karma output too then give it to Spirit as an example, I just need to get motivated to give the little amount of time that I have available, to it. ;-) I'm still interested in just the Spirit 2.1 grammar for JSON if you don't mind, to implement just an event-based SAX-like parser for JSON. I'd happily use a full reading and writing impl, but I'd be happy with just the grammar for now.
(*hint* poke me to get it done, random emails, that helps a ton). Consider yourself poked ;) Thanks, --DD
[...]
Yuck, that really is ugly... That should show you how it works, but yeah, wait until I can actually redesign it. I do not have time right this moment (keep poking me and I may have this odd hour here or there), but should have some dedicated time late next week, just keep on poking/emailing me.
Poke poke poke poke poke... hmmm is that enough for a week's poke? ;-) Ah need two more: poke poke. :-) Regards, -- Joel de Guzman http://www.boostpro.com http://spirit.sf.net http://www.facebook.com/djowel Meet me at BoostCon http://www.boostcon.com/home http://www.facebook.com/boostcon
participants (4)
-
Dominique Devienne
-
Joel de Guzman
-
OvermindDL1
-
Sebastian Redl