Cory Zue wrote:
On Fri, May 14, 2010 at 12:40 PM, Nils Breunese<[email protected]> wrote:
Cory Zue wrote:
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.
I was thinking of the xsd way of dealing with this by prefixing
attributes with "@", which in your case would look like:
{
"@problem": "yes"
"type": "person",
"problem": "This is a problem.",
"name": "Nils"
}
Yeah, you could use an "@" instead of an underscore, but that still
wouldn't get you the above I guess. I think you'd get a nested structure
like this:
{
"person": {
"@problem": "yes",
"problem": "This is a problem.",
"name": "Nils"
}
}
So I'd prefer a custom transformation myself anyway.
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.