Giter VIP home page Giter VIP logo

Comments (2)

GoogleCodeExporter avatar GoogleCodeExporter commented on July 26, 2024
Hi!
Well, it's a good way to contact me here, why not? :)

The problem you are describing isn't easy to solve without additional 
XSD/knowledge and I can't promise anything right now. I'll think about any 
workaround/solution. 
Thanks!

Original comment by [email protected] on 11 Dec 2013 at 5:37

  • Changed state: Accepted

from x2js.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 26, 2024
Nice library unfortuantly the element order is quite a big one for me as well. 
One idea I have for fixing this is to simply put a wrapper on elements that 
contains their tag name. Currently given this xml input

<root>
  <tag1 hello="world" />
  <tag2 />
  <tag1 />
</root>

you get this json

{
   "root":{
      "tag1":[
         {
            "_hello":"world"
         },
         ""
      ],
      "tag2":""
   }
}

As you can see no order. Now imagine if the json returned was this

[
   {
      "namespace": "",
      "localName": "root"
      "children": [
         {
            "namespace": "",
            "localName": "tag1",
            "children": [],
            "attributes": {
               "hello": "world"
            }
         },
         {
            "namespace": "",
            "localName": "tag2",
            "children": [],
            "attributes": {}
         },
         {
            "namespace": "",
            "localName": "tag1",
            "children": [],
            "attributes": {}
         },
      ]
   }
]


This output is much more verbose but it has its benefits, for 1 order is 
preserved and additional information can be added without conflicting with 
attribute names. Because this changes the whole structure of the response a 
change like this would have to a v2 change.


Original comment by [email protected] on 23 Jun 2014 at 10:30

from x2js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.