1

I'm doing this project that I need to save a full character array into a string. I want to have the [] characters in the string.

Example:
aArray = [
[0,0,0,0],
[0,0,0,0],
[0,0,0,0],
[0,0,0,0]
];

myString = aArray.toString();
trace(myString);

In my output I get:

0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0...

I want the [] brackets.

1 Answer 1

1
var aArray:Array = [
[0,0,0,0],
[0,0,0,0],
[0,0,0,0],
[0,0,0,0]
];

var string:String =  JSON.encode(aArray);

trace(string);

output :

"[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]]"
Sign up to request clarification or add additional context in comments.

2 Comments

What i have to import to use that?
If you are going to use JSON.encode you need github.com/mikechambers/as3corelib. If you target flash player 11 and up you can use the native JSON class and JSON.stringify method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.