[property_tree] Parsing vectors of objects

Hello, I want to parse to and from Xml (or possibly Json) using the property tree. I've got a simple POCO parsing, but now I need to include vectors of objects. Furthermore, I understand the property tree paths are pretty cumbersome. Not so much through a thin vernier, template function, something like that, but anywho... Here's the desired output I want in Xml, something like this: <output> <apples> <apple grower="red" /> <apple grower="green" /> <apple grower="golden" /> </apples> <oranges> <orange freshness="picked" /> <orange freshness="market" /> <orange freshness="store" /> </oranges> <items> <item name="" id="">1234</item> <item name="" id="">1234</item> <item name="" id="">1234</item> </items> </output> I understand the tree path might look something like this "output.apples.apple.<xmlattr>.grower", but what about the vector? Probably want to be trimming white spaces, indenting, as well. Regards, Michael Powell

On Sun, Jul 21, 2013 at 2:30 PM, Michael Powell
I want to parse to and from Xml (or possibly Json) using the property tree.
Bad idea. See http://boost.2283326.n4.nabble.com/Using-property-tree-as-json-reader-writer... To be short: if you want to manipulate XML or JSON, use XML and JSON libraries. Property Tree is a format in itself and serialization functions are only there to make ptree easy to move into another format, not the other way arround. Because ptrees can't represent all xml or JSON can. PTree is useful both as container and if you don't care much about the specific input format. As soon as you decided to use a specifc input format which can represent more than ptree can represent, it becomes far less useful. Joel Lamotte

Thank ye. I did not know this, although it makes sense.
On Sun, Jul 21, 2013 at 10:11 AM, Klaim - Joël Lamotte
On Sun, Jul 21, 2013 at 2:30 PM, Michael Powell
wrote: I want to parse to and from Xml (or possibly Json) using the property tree.
Bad idea. See http://boost.2283326.n4.nabble.com/Using-property-tree-as-json-reader-writer...
To be short: if you want to manipulate XML or JSON, use XML and JSON libraries. Property Tree is a format in itself and serialization functions are only there to make ptree easy to move into another format, not the other way arround. Because ptrees can't represent all xml or JSON can.
PTree is useful both as container and if you don't care much about the specific input format. As soon as you decided to use a specifc input format which can represent more than ptree can represent, it becomes far less useful.
Joel Lamotte
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Klaim - Joël Lamotte
-
Michael Powell