Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON encoding support for __HTMLScriptObjects / __HTMLScriptArrays #182

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Added support for __HTMLScriptArrays and __HTMLScriptObjects.
brianreavis committed Jan 27, 2012
commit 6093ef4466b55673e4c8001c0bb8c7c2491c31d8
8 changes: 6 additions & 2 deletions src/com/adobe/serialization/json/JSONEncoder.as
Original file line number Diff line number Diff line change
@@ -198,6 +198,10 @@ package com.adobe.serialization.json
*/
private function arrayToString( a:Array ):String
{
// arrays of the __HTMLScriptArray type use string keys rather than numeric keys
var typeName:String = describeType( a )[email protected]();
var isScriptArray:Boolean = (typeName == "flash.html::__HTMLScriptArray" || typeName == "flash.html::__HTMLScriptObject");

// create a string to store the array's jsonstring value
var s:String = "";

@@ -215,7 +219,7 @@ package com.adobe.serialization.json
}

// convert the value to a string
s += convertToString( a[ i ] );
s += convertToString( a[ isScriptArray ? i.toString() : i ] );
}

// KNOWN ISSUE: In ActionScript, Arrays can also be associative
@@ -251,7 +255,7 @@ package com.adobe.serialization.json

// determine if o is a class instance or a plain object
var classInfo:XML = describeType( o );
if ( [email protected]() == "Object" )
if ( [email protected]() == "Object" || [email protected]() == "flash.html::__HTMLScriptObject" )
{
// the value of o[key] in the loop below - store this
// as a variable so we don't have to keep looking up o[key]