Thanks, I'll look into that strategy -- Matt Perkins ----------------- http://www.nudoru.com
On Jul 28, 2010, at 7:43 PM, Taka Kojima <[email protected]> wrote: > The JSON encoder class might do it automatically by passing an XML object to > the constructor, idk, look into it maybe. > > It's also not very hard to loop through an XML node and convert all of it's > attributes and children nodes into an object, something like this: > > (I took 40 seconds to write this, please don't use this in production code > without proper testing/verification). > > function xmlToObj($xml:XML):Object{ > var obj:Object = {}; > for each(var node:XML in $xml.children()){ > obj[node.name()] = xmlToObj(node); > } > var attributes:XMLList = $x...@*; > for (var i:int = 0; i < attributes.length(); i++){ > trace(attributes[i].name()); > obj[String(attributes[i].name())] = attributes[i]; > } > return obj; > } > > On Wed, Jul 28, 2010 at 3:51 PM, Matt Perkins <[email protected]> wrote: > >> Right, learn was probably a strong word. Just meant that I'd never >> used it before. >> >> Is there an automated was to convert the XML to JSON with AS3? >> >> -- >> Matt Perkins >> ----------------- >> http://www.nudoru.com >> >> On Jul 28, 2010, at 6:12 PM, Taka Kojima <[email protected]> wrote: >> >>> There isn't really anything such as "learning JSON", JSON is basically >> just >>> an object, and is your best bet. >>> >>> You can convert an XML string to JSON, store it, and then when you need >> it >>> reconvert it to XML if you really need to, but unless you're doing things >>> with E4X that is probably unnecessary. >>> >>> There are several libraries for a number of different languages to work >> with >>> JSON, a lot of languages have the functionality built in, for AS3 you can >>> use the as3 core lib or you can use this: >>> >>> http://www.thanksmister.com/index.php/archive/json-lite/ >>> >>> >>> Taka >>> >>> On Wed, Jul 28, 2010 at 3:03 PM, Matt Perkins <[email protected]> >> wrote: >>> >>>> Wondering if someone has had this problem and found a good solution ... >>>> >>>> I've developed a social simulation that has a lot of data that i need to >>>> save between user sessions in the suspend_data SCORM variable to our >> LMS. >>>> I'm formatting this data as XML since 1, has a good structure and 2, i >> know >>>> it. Suspend_data only has 4k of space and my XML (as a string) is pretty >> big >>>> - doubly so since the LMS encodes it and all of the single char <, > and >> /'s >>>> get turned into 4 chars. But i've used attributes and 1-2 char tag names >>>> where i can. >>>> >>>> I'm going to try to compress the string with ByteArray and see if that >>>> helps, but I'm not sure if the "special characters" will mess with the >> LMS >>>> communication - I've had that happen many times before with just HTML >> page >>>> text. >>>> >>>> Other option is to learn JSON and do it that way. >>>> >>>> Have anyone else faced something like this and solved it? >>>> >>>> -- >>>> Matt Perkins >>>> -------------------- >>>> http://www.nudoru.com >>>> >>>> _______________________________________________ >>>> Flashcoders mailing list >>>> [email protected] >>>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders >>>> >>> _______________________________________________ >>> Flashcoders mailing list >>> [email protected] >>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders >> _______________________________________________ >> Flashcoders mailing list >> [email protected] >> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders >> > _______________________________________________ > Flashcoders mailing list > [email protected] > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders _______________________________________________ Flashcoders mailing list [email protected] http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

