Re: [json-lib-user] Order of child elements is switched when converting from json to xml
Brought to you by:
aalmiray
From: Olivier C. <oli...@gm...> - 2011-11-22 15:19:22
|
While we are at it, it would be great if you could also support BadgerFish (in particular, the possibility to NOT loose the name of elements of a list: <myList> <myElement>xxx</myElement> <myElement>yyy</myElement> </myList> => should return myList:{myElement:[xxx,yyy]} If you can have this, I'm your first fan ;-) Thanks (and I understand it's complicated to do everything ;-) Olivier On Tue, Nov 22, 2011 at 4:14 PM, Alan Hicks <al....@gm...> wrote: > I must look at committing a patch with an optional value to turn on/off > sorting. At the time we had some deadlines that meant I could not do this > and then got caught up with other items. > > > > On Tuesday, November 22, 2011, Olivier Chirouze < > oli...@gm...> wrote: > > Funny :-) Thanks for sharing the feedback. > > That proves how useful this line is! I don't really like that solution > though... > > In the meantime, I implemented a solution with more lines of code but > that seems to get all I need: > > - a xml2json.xsl stylesheet for XML => JSON (advantage: can use > "BadgerFish" convention) > > - jettison for JSON => XML (but quite complicated to implement) > > So, in a word I did without JSON-lib but what a shame! > > Olivier > > On Tue, Nov 22, 2011 at 3:54 PM, Alan Hicks <al....@gm...> wrote: > > > > We are using this library to convert from JSON to XML and XML to JSON. > To get around the sorting issue we just commented out the call to > "Arrays.sort( names );" in the Serializer. We have been using it like this > since April 2010 with no issues. > > > > On Tuesday, November 22, 2011, Olivier Chirouze < > oli...@gm...> wrote: > >> I though the "reply-all" was set to reply to > jso...@li...! :-) > >> Thanks for your reply anyway. Hope someone can react since I could not > play with bug reports on Sourceforge! > >> Olivier > >> > >> On Tue, Nov 22, 2011 at 3:25 PM, Morgan Packard < > mo...@mo...> wrote: > >>> > >>> I'm afraid I'm just a dumb user of this project, I'm not involved in > authoring or maintaining it in any way, so i'm not the right guy to ask > about line 942. > >>> -Morgan > >>> > >>> On Tue, Nov 22, 2011 at 3:52 AM, Olivier Chirouze < > oli...@gm...> wrote: > >>>> > >>>> Ok, I found what I see as a very strange... bug? > >>>> Line 942 of XMLSerializer.java, in method processJSONObject(), I > found... > >>>> Arrays.sort( names ); > >>>> Why is it there for? I don't see the point in sorting elements, > especially if the output is to be an XML. To me this line is 100% useless. > >>>> I found existing bug entries on sourceforge and will try to push the > resolution of these. > >>>> Olivier > >>>> > >>>> On Tue, Nov 22, 2011 at 9:11 AM, Olivier Chirouze < > oli...@gm...> wrote: > >>>>> > >>>>> I agree with you. > >>>>> But XML elements ARE ordered, right? > >>>>> So, when one passes a list of JSON objects in a specific order, why > change that order when converting to XML??? > >>>>> > >>>>> On Mon, Nov 21, 2011 at 5:49 PM, Morgan Packard < > mo...@mo...> wrote: > >>>>>> > >>>>>> I was under the impression that json dictionaries are unordered > according to the spec. > >>>>>> from json.org: > >>>>>> > >>>>>> JSON is built on two structures: > >>>>>> > >>>>>> A collection of name/value pairs. In various languages, this is > realized as an object, record, struct, dictionary, hash table, keyed list, > or associative array. > >>>>>> An ordered list of values. In most languages, this is realized as > an array, vector, list, or sequence. > >>>>>> > >>>>>> On Mon, Nov 21, 2011 at 11:45 AM, Olivier Chirouze < > oli...@gm...> wrote: > >>>>>>> > >>>>>>> Hi there, > >>>>>>> I am playing with JSON lib conversion from JSON to XML and the > opposite. > >>>>>>> I am now facing a strange issue: converting from json string to > XML seems to loose the order of elements in the process. > >>>>>>> However in debug I can make sure the "insertOrder" property of my > JSONObject is right! But xmlSerializer.write(myJSONObject) returns an XML > string where child elements have been mixed up (seems to be exactly the > opposite order!!...) > >>>>>>> What should I do? > >>>>>>> Thanks > >>>>>>> > ------------------------------------------------------------------------------ > >>>>>>> All the data continuously generated in your IT infrastructure > >>>>>>> contains a definitive record of customers, application performance, > >>>>>>> security threats, fraudulent activity, and more. Splunk takes this > >>>>>>> data and makes sense of > |