How to convert a JSON object to XML in AS3?

2

There is some method of converting a JSON object to an XML object using

asked by anonymous 17.02.2014 / 19:50

1 answer

1

I was able to do the conversion by creating this method that worked well:

function jsonToXML(obj:Object):XML {
    var to:XML = new XML(<root></root>);
    ad(to, obj);
    function ad(c:*, b:*):void {
       for(var a:Object in b) {
          if(b[a].toString() == "[object Object]") {
              c.appendChild(<{a}></{a}>);
              ad(c[a], b[a]);
          }
          else {
              c.appendChild(<{a}>{b[a]}</{a}>);
          }
       }
    }
    return to;
}
    
18.02.2014 / 17:03