Giter Site home page Giter Site logo

'arrays in arrays' about x2js HOT 7 CLOSED

mgaert avatar mgaert commented on June 24, 2024
'arrays in arrays'

from x2js.

Comments (7)

GoogleCodeExporter avatar GoogleCodeExporter commented on June 24, 2024
Hmm... It is interesting idea. Thanks! I'll think about it.

Original comment by [email protected] on 11 Oct 2013 at 9:32

  • Changed state: Accepted
  • Added labels: Type-Enhancement
  • Removed labels: Type-Defect

from x2js.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 24, 2024
And Thank you! I forgot :) 
Love this lib. 
Will just stroll down the "old" _asArray-road for now. NP!

Inspiration could by the way be found here (in actionscript):
http://krasimirtsonev.com/blog/article/as3-action-script-convert-xml-to-json-xml
2json 

Original comment by [email protected] on 11 Oct 2013 at 9:48

from x2js.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 24, 2024
I've just added a new feature to v1.1.3
(You always can look it at 
https://code.google.com/p/x2js/source/browse/xml2json.js or download from 
https://x2js.googlecode.com/hg/xml2json.js)

You can do now like this, for your example:
var x2js = new X2JS({
   arrayAccessFormPaths : ["json.setup.templates.template", "json.setup.templates.template.states.state"]
});
var json = x2js.xml2json(xmldoc);

And access like the other JS objs:
json.setup.templates.template[0].states.state

You can specify also paths to arrays as RegEx form:
var x2js = new X2JS({
   arrayAccessFormPaths : [/.*\.template/, /.*\.state/]
});

Let me know if it works for you! Thanks!

Original comment by [email protected] on 12 Oct 2013 at 11:11

from x2js.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 24, 2024
Also if you need some powerful XPath like tool on JSon there some additional 
libraries. 
For example I've just googled it - http://goessner.net/articles/JsonPath/ :)

Original comment by [email protected] on 12 Oct 2013 at 11:36

  • Changed state: Fixed

from x2js.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 24, 2024
[deleted comment]

from x2js.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 24, 2024
Perfect!  Nothing less.
Rewrote my project to use the arrayAccessFormPath  and it simply worked. 
Thank you!

Haven't tested the json xpath yet. But I sure will. 

Original comment by [email protected] on 14 Oct 2013 at 8:32

from x2js.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 24, 2024
I appreciate for your feedback and interest! Thank you!
Well, I'm closing this one for now then.

Original comment by [email protected] on 14 Oct 2013 at 8:38

  • Changed state: Done

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.