How to convert a JSON object to XML in AS3?

Asked

Viewed 237 times

2

Is there any method of converting a JSON object to an XML object using the with Flash CS6?

1 answer

1


I was able to perform 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;
}
  • it seems that you do everything alone here at SOPT kkkk

Browser other questions tagged

You are not signed in. Login or sign up in order to post.