Custom Object does not fully encode into JSON Object
I have the following class:
public class PartBean extends DatabaseObjectBean{
[开发者_运维技巧Bindable]
public var partNumber:String;
[Bindable]
public var description:String;
public var enterpriseIdentifiers:ArrayList;
}
Part is already defined as such. Part Number = -1 Description = Test The list is filled with another Object["Name1", "Name2, "Name3"] etc..
In another object I call:
import com.adobe.serialization.json.JSONEncoder;
public function blah(){
JSONEncoder encoder = new JSONEncoder();
Alert.show(encoder.encode(part);
}
I end up with this string: {"description":"Test","partNumber":"-1"}
I am not sure why the array is not being encoded as well.
You'll have to write your own serialization code for the ArrayList. The JSON encoder provided with ActionScript will only encode native ActionScript objects.
It seems the answer is simply that the encoder needs the items to be bindable in order to see them.
[Bindable]
public var enterpriseIdentifiers:ArrayList;
精彩评论