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

JSON representation for XML snippet

Expand Messages
  • Shalab Goel
    Hello, Is there a standard way to represent the information in following XML snippet as JSON output. value1
    Message 1 of 3 , Sep 14, 2009
    • 0 Attachment
      Hello,

      Is there a standard way to represent the information in following XML
      snippet
      as JSON output.

      <attributes>
      <attribute a1="v1">value1</attribute>
      <attribute a2="v2">value2</attribute>
      </attributes>

      Is there an online tool that would generate this conversion?

      Appreciate your response.

      ~S


      [Non-text portions of this message have been removed]
    • Andrea Giammarchi
      In taht way you are loosing data type. If interested, this is not that standard but kinda an easy spec to follow (plus a script)
      Message 2 of 3 , Sep 14, 2009
      • 0 Attachment
        In taht way you are loosing data type.
        If interested, this is not that standard but kinda an easy spec to follow
        (plus a script)
        http://webreflection.blogspot.com/2008/07/jxon-lossless-javascript-to-xml-object.html

        Hope will help somehow


        On Mon, Sep 14, 2009 at 5:17 PM, Shalab Goel <goel.shalab@...> wrote:

        >
        >
        > Hello,
        >
        > Is there a standard way to represent the information in following XML
        > snippet
        > as JSON output.
        >
        > <attributes>
        > <attribute a1="v1">value1</attribute>
        > <attribute a2="v2">value2</attribute>
        > </attributes>
        >
        > Is there an online tool that would generate this conversion?
        >
        > Appreciate your response.
        >
        > ~S
        >
        > [Non-text portions of this message have been removed]
        >
        >
        >


        [Non-text portions of this message have been removed]
      • Tatu Saloranta
        ... It depends on what you d expect to get out of it, but I think the answer is no: there is nothing obvious and standard. It really depends on meaning of data
        Message 3 of 3 , Sep 14, 2009
        • 0 Attachment
          On Mon, Sep 14, 2009 at 9:17 AM, Shalab Goel <goel.shalab@...> wrote:
          > Hello,
          >
          > Is there a standard way to represent the information in following XML snippet
          > as JSON output.
          >
          > <attributes>
          >  <attribute a1="v1">value1</attribute>
          >  <attribute a2="v2">value2</attribute>
          > </attributes>
          >
          > Is there an online tool that would generate this conversion?

          It depends on what you'd expect to get out of it, but I think the
          answer is no: there is nothing obvious and standard.
          It really depends on meaning of data above.

          <rant>
          personally I think it is better to convert from original data
          (objects, relational data) into structurally distinct data formats
          (xml and json have fundamentally differen data models, hierachic vs
          struct/frame/object model... but I digress). And as such, if possible,
          it's better to figure out meaning of data and then produce "native"
          xml and json, without trying to convert from json to xml or vice
          versa. Latter is more difficult, and data in one (... or both) of
          formats will end up looking funny and somewhat unreadable
          </rant>

          Anyway: instead of "the" standard, there however multiple competing
          standard proposals (called "mapping conventions") that do allow
          converting any XML content into well-formed (if bit odd-looking and
          alien-feeling :) ) JSON.
          One such convention is Badgerfish (see, for example
          [http://sujitpal.blogspot.com/2007/10/converting-xml-to-badgerfish-json.html%5d);
          and there are multiple others that claim to produce natural JSON.

          -+ Tatu +-
        Your message has been successfully submitted and would be delivered to recipients shortly.