I like the idea of json config files but how to handle cases where a element can occur multiple times? With only one element, it would generate an object, but with multiple elements it would change into an array. This might make the code which reads the config a bit more difficult/error prone because it needs to check the type everytime. What do you guys think? Or is this a non-issue? Btw, I took a part of a plugin.xml as an example. Xml: <engines> <engine name="cordova-android" version=">=3.2.0" /> <engine name="cordova-ios" version=">=3.0.0" /> </engines> Jason (array because engine element is found multiple times): { "engines": { "engine": [ { "-version": ">=3.2.0", "-name": "cordova-android" }, { "-version": ">=3.0.0", "-name": "cordova-ios" } ] } }
Or json with only one engine in the xml (so an object) "engine": { "-version": ">=3.2.0", "-name": "cordova-android" } ---------------------------------------- > From: jbo...@gdesolutions.com > To: dev@cordova.apache.org > Subject: RE: XML Namespaces > Date: Sat, 15 Feb 2014 18:34:46 +0000 > > On Fri Feb 14 02:30 PM, Marcel Kinard wrote: >> >> On Feb 13, 2014, at 10:04 AM, Jonathan Bond-Caron >> <jbo...@gdesolutions.com> wrote: >> >>> IBM most likely would prefer XML for the XSD & tooling... >> >> Not necessarily. Schema validation is nice, but XML for the sake of XML >> doesn't >> make sense. What makes more sense is following standards where reasonably >> possible. But if the widget spec is deprecated and we are making a conscious >> decision to abandon it, then the leaning for XML goes away. Given the >> audience >> of web devs, and the use of json config in other places, my preference would >> be >> for json config. > > Great to have your opinion, my guesswork was that for a plugman based project > on android for example, xml would be preferred. > >> >>> Note about xml vs. json config, Cordova could support both. >> >> Cordova could, but that seems to me like overkill. If someone really wants >> xml, >> how about providing an xslt that translates the xml to json, so they can >> author in >> xml and Cordova could read json. But even that sounds like overkill too. > > It turns out there's a great node lib called 'xml2js', the code to do this is > pretty simple: > https://github.com/jbondc/cordova-labs/blob/master/cordova-lib/test.js > > https://github.com/jbondc/cordova-labs/blob/master/cordova-lib/config.ts > https://github.com/jbondc/cordova-labs/blob/master/cordova-lib/config.js > > So the idea here is: > - config.xml, config.json > - plugin.xml, plugin.json > > Would both be supported, with json being looked for first. >