incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nils Breunese <N.Breun...@vpro.nl>
Subject Re: _update, XML, and POST
Date Fri, 14 May 2010 10:40:29 GMT
Cory Zue wrote:

> Second, is there a community recommended XML to JSON library to
> perform the data transfer?  I've been evaluating several (listed
> below), none of which seem to be highly active, recent, or well
> established.  Anyone done this before and want to make a
> recommendation?  I'm surprised that there's not a de-facto choice for
> this.

Actually I'm not really surprised, since XML is a more complex data
format than JSON, so there is no true 1-to-1 mapping. Consider XML
attributes and elements for instance. Initially you might think mapping
them to JSON name/value pairs is a good idea, but attributes and
elements can have the same name:

<person problem="yes">
   <problem>This is a problem.</problem>
   <name>Nils</name>
</person>

How would you represent this in JSON? You might prefix attributes with
underscores or something, but it starts getting clunky fast.

For CouchDB purposes I'd want to map the XML above into a custom
structure anyway, so I guess I'd just write my own custom conversion
anyway (map root element to type property, omit the problem attribute)
to produce something like:

{
   "type": "person",
   "problem": "This is a problem.",
   "name": "Nils"
}

Converting JSON to XML is easy, the other way around is not trivial.

Nils.

De informatie vervat in deze  e-mail en meegezonden bijlagen is uitsluitend bedoeld voor gebruik
door de geadresseerde en kan vertrouwelijke informatie bevatten. Openbaarmaking, vermenigvuldiging,
verspreiding en/of verstrekking van deze informatie aan derden is voorbehouden aan geadresseerde.
De VPRO staat niet in voor de juiste en volledige overbrenging van de inhoud van een verzonden
e-mail, noch voor tijdige ontvangst daarvan.

Mime
View raw message