Re: [json-lib-user] Problem collecting elements of identical name in a array
Brought to you by:
aalmiray
From: Andres A. <aal...@ya...> - 2009-09-21 16:33:33
|
Hi Rodolfo, Looks like a bug to me. Please file a bug ticket, thank you! Cheers, Andres ------------------------------------------- http://jroller.com/aalmiray http://www.linkedin.com/in/aalmiray -- What goes up, must come down. Ask any system administrator. There are 10 types of people in the world: Those who understand binary, and those who don't. To understand recursion, we must first understand recursion. ________________________________ From: Rodolfo Bunney <ro...@id...> To: jso...@li... Sent: Monday, September 21, 2009 2:17:56 AM Subject: [json-lib-user] Problem collecting elements of identical name in a array Hi! I'm trying to write JSON from an existing XML document and got a problem with collecting all the elements with identical names. If my identical named elements are the only ones in the same depth in the XML document, the parser has no problem converting the document. But if I have several siblings where a couple of them are identical, the result JSON is not transformed correctly. I'm doing this from a Groovy script.: import net.sf.json.xml.XMLSerializer import net.sf.json.JSON def xml = """<body> <menulist> <titles><foo>foo1</foo><foo>foo2</foo></titles> <item> <value><name>item1</name><action>doAction</action></value> </item> <item> <value><name>item2</name><action>doAction</action></value> </item> </menulist> </body>""" XMLSerializer serializer = new XMLSerializer() JSON json = serializer.read(xml) return json.toString() The JSON result: [ { "titles": [ "foo1", "foo2" ], "item": [ { "name": "item1", "action": "doAction" }, [ { "name": "item2", "action": "doAction" } ] ] } ] If I remove the <titles> node the XML document is correctly parsed. Does anyone else have the same problem? Or maybe have a nice workaround? -- Rodolfo Bunney <ro...@id...> Systemutvikler @ http://www.idium.no Sommerrogata 13-15, N-0255 Oslo, Norway 22 00 84 00 |