From: Stephan B. <sg...@go...> - 2010-04-08 14:41:49
|
i finally found the dev list address at the bottom/right of the doxygen docs, so i'm re-sending this to the list... ---------- Forwarded message ---------- From: Stephan Beal <sg...@go...> Date: Thu, Apr 8, 2010 at 3:17 PM Subject: jsoncpp and libs11n To: bl...@us... Hi, Babtiste! i am the author of the libs11n project (http://s11n.net), a generic serialization framework for C++, and i wanted to take a moment to tell you how i'm using jsoncpp... Brief overview: s11n is, unlike most serialization frameworks, ignorant of any data types. Like jsoncpp, it uses a DOM-like structure, and arbitrary i/o formatters can be written which use those DOM-like structures. s11n currently has 6 or 8 different data formats, and was the first serialization library ever (AFAIK) to be able to serialize C++ objects directly to email ( http://blog.s11n.net/?p=17). Anyway... i only came across jsoncpp yesterday, during my semi-monthly searches for C/C++-based JSON i/o handlers. So far jsoncpp is the only one where i've look at it and said, "yes! This is an API i can enjoy using!" Last night i started writing an i/o handler based on your code (with only 1 small patch), and we can now serialize near-arbitrary C++ objects to json :). Over the weekend i'll get the input support working. i was going to suggest the addition of an event-based parser (it would significantly cut the memory costs for deserialization in my case), but i see you've added it to your jsoncpp roadmap :). As a demonstration, here we'll serialize a std::vector< std::list<T> > ... int main() { using namespace Json; namespace sio = s11n::io; namespace sli = s11nlite; typedef s11n::Detail::variant Var; if(1) { typedef Var ValueT; typedef std::list<ValueT> LT; LT list; int i = 0; for( i = 0; i < 5; ++i ) { list.push_back( "Var #"+Var(i).str() ); list.push_back( Var(i*1.33) ); list.push_back( Var(i) ); } sli::node_type no; typedef sio::json_serializer<sli::node_type> SerT; s11nlite::serialize( no, list ); SerT ser; //ser.serialize( no, std::cout ); typedef std::vector< LT > VT; VT vec; for( i = 0; i < 2; ++i ) { vec.push_back( list ); } //sli::node_traits::clear( no ); //s11nlite::serialize( no, list ); sli::node_traits::clear( no ); s11nlite::serialize( no, vec ); ser.serialize( no, std::cout ); } return 0; } that produces output like: {"s11nIoJsonSerializer": {"name":"s11n_node", "s11nClass":"vector", "children":[ {"name":"s11n_node", "s11nClass":"list", "properties":{ "x00":"Var #0", "x01":0, "x02":0, "x03":"Var #1", "x04":1.330, "x05":1, "x06":"Var #2", "x07":2.660, "x08":2, "x09":"Var #3", "x0a":3.990, "x0b":3, "x0c":"Var #4", "x0d":5.320, "x0e":4 } } ] ... } } (the 'x' prefixes on the properties are there for long historical reasons involving requirements for 'key' elements for certain data formats... only array/list-like classes do that.) Not only that, but we can easily convert between any of s11n's supported formats (i think it now has 7 or 8) and json by using s11nconvert ( http://s11n.net/s11nconvert/) or the C++ API (it only takes a couple lines of code to convert arbitrary serialized objects). i have a couple tiny additions to jsoncpp i would like to submit for your consideration. What channel do you prefer for that? Is here a mailing list or google group? Anyway... i thought you might like to know that someone's getting some good use out of your code. Happy hacking!! And THANK YOU VERY MUCH for releasing jsoncpp into the Public Domain (http://s11n.net/license.php). -- ----- stephan beal http://wanderinghorse.net/home/stephan/ -- ----- stephan beal http://wanderinghorse.net/home/stephan/ |
From: Stephan B. <sg...@go...> - 2010-04-08 14:44:26
|
My appologies if this hits the list twice... the jsoncpp docs say to send comments to the list but don't say it is a subscriber-only list.... ---------- Forwarded message ---------- From: Stephan Beal <sg...@go...> Date: Thu, Apr 8, 2010 at 4:41 PM Subject: Fwd: jsoncpp and libs11n To: jso...@li... i finally found the dev list address at the bottom/right of the doxygen docs, so i'm re-sending this to the list... ---------- Forwarded message ---------- From: Stephan Beal <sg...@go...> Date: Thu, Apr 8, 2010 at 3:17 PM Subject: jsoncpp and libs11n To: bl...@us... Hi, Babtiste! i am the author of the libs11n project (http://s11n.net), a generic serialization framework for C++, and i wanted to take a moment to tell you how i'm using jsoncpp... Brief overview: s11n is, unlike most serialization frameworks, ignorant of any data types. Like jsoncpp, it uses a DOM-like structure, and arbitrary i/o formatters can be written which use those DOM-like structures. s11n currently has 6 or 8 different data formats, and was the first serialization library ever (AFAIK) to be able to serialize C++ objects directly to email ( http://blog.s11n.net/?p=17). Anyway... i only came across jsoncpp yesterday, during my semi-monthly searches for C/C++-based JSON i/o handlers. So far jsoncpp is the only one where i've look at it and said, "yes! This is an API i can enjoy using!" Last night i started writing an i/o handler based on your code (with only 1 small patch), and we can now serialize near-arbitrary C++ objects to json :). Over the weekend i'll get the input support working. i was going to suggest the addition of an event-based parser (it would significantly cut the memory costs for deserialization in my case), but i see you've added it to your jsoncpp roadmap :). As a demonstration, here we'll serialize a std::vector< std::list<T> > ... int main() { using namespace Json; namespace sio = s11n::io; namespace sli = s11nlite; typedef s11n::Detail::variant Var; if(1) { typedef Var ValueT; typedef std::list<ValueT> LT; LT list; int i = 0; for( i = 0; i < 5; ++i ) { list.push_back( "Var #"+Var(i).str() ); list.push_back( Var(i*1.33) ); list.push_back( Var(i) ); } sli::node_type no; typedef sio::json_serializer<sli::node_type> SerT; s11nlite::serialize( no, list ); SerT ser; //ser.serialize( no, std::cout ); typedef std::vector< LT > VT; VT vec; for( i = 0; i < 2; ++i ) { vec.push_back( list ); } //sli::node_traits::clear( no ); //s11nlite::serialize( no, list ); sli::node_traits::clear( no ); s11nlite::serialize( no, vec ); ser.serialize( no, std::cout ); } return 0; } that produces output like: {"s11nIoJsonSerializer": {"name":"s11n_node", "s11nClass":"vector", "children":[ {"name":"s11n_node", "s11nClass":"list", "properties":{ "x00":"Var #0", "x01":0, "x02":0, "x03":"Var #1", "x04":1.330, "x05":1, "x06":"Var #2", "x07":2.660, "x08":2, "x09":"Var #3", "x0a":3.990, "x0b":3, "x0c":"Var #4", "x0d":5.320, "x0e":4 } } ] ... } } (the 'x' prefixes on the properties are there for long historical reasons involving requirements for 'key' elements for certain data formats... only array/list-like classes do that.) Not only that, but we can easily convert between any of s11n's supported formats (i think it now has 7 or 8) and json by using s11nconvert ( http://s11n.net/s11nconvert/) or the C++ API (it only takes a couple lines of code to convert arbitrary serialized objects). i have a couple tiny additions to jsoncpp i would like to submit for your consideration. What channel do you prefer for that? Is here a mailing list or google group? Anyway... i thought you might like to know that someone's getting some good use out of your code. Happy hacking!! And THANK YOU VERY MUCH for releasing jsoncpp into the Public Domain (http://s11n.net/license.php). -- ----- stephan beal http://wanderinghorse.net/home/stephan/ -- ----- stephan beal http://wanderinghorse.net/home/stephan/ -- ----- stephan beal http://wanderinghorse.net/home/stephan/ |