Loading ...
Sorry, an error occurred while loading the content.

1386Re: SV: [json] JSON representation for XML snippet

Expand Messages
  • Mark Joseph
    Sep 14, 2009
      From: Shalab Goel [mailto:goel.shalab@...]
      To: json@yahoogroups.com
      Sent: Mon, 14 Sep 2009 14:23:34 -0700
      Subject: Re: SV: [json] JSON representation for XML snippet

      Thank you for all the responses. I guess there were two parts to it. I was
      specifically interested in your insights on a XML element with both text and
      can be represented in JSON.

      <attribute a2="v2">value2</attribute>

      If XML were

      <attribute a2="v2">value2</attribute>

      equivalent JSON could be

      {"attribute" : "value2"}

      if XML were

      <attribute a2="v2" />

      JSON could be

      "attribute" :
      { "a2" : "v2" }

      But how about when both XML element's text and attributes are specified
      as in

      <attribute a2="v2">value2</attribute>

      It would be great if there was a standard defined for the transformation, but
      other than that I can only mention what I have done.

      I have played with both formats:

      a flat format:
      { "attribute" : "value2",
      "a2" : "v2"


      An array format:
      { "attribute" : [ { "a2" : "v2" }, { "value2" } ] }

      Of course, with either of these outputs we lose something and cannot easily turn this
      back into XML afterwards. Since JSON has no attributes I have no solution unless
      everyone agrees to what the mapping should be.


      Mark Joseph, Ph.D.
      P6R, Inc
      Skype: markjoseph_sc
    • Show all 28 messages in this topic