0 Replies Latest reply on Sep 29, 2008 8:14 AM by garry.b

    XML-to-JSON conversion?

    garry.b
      Hi,

      I'm interested in converting between xml and json and, once converted,
      pretty-printing the json result. While there seem to be plenty of .Net solutions
      that do the job, I'm looking for an AS or javascript solution. I did cobble
      together a couple of tools as follows:

      var xml_doc = XMLObjectifier.textToXML("<name>Howdy</name>"); //Converts xml string to xml dom
      var json = XMLObjectifier.xmlToJSON(xml_doc); //Converts xml dom object to JSON
      var json_string = JSON.stringify(json); // converts json object to string

      However, the resulting string is - as advertised - a json representation of the
      dom tree; I want a json representation of the original xml document absent
      dom node artifacts like text, content, etc. What's the best way to do this?

      Thanks, Garry