I have the following js array/object
var x = [1,2,3,4];
x.name = "myArray";
I am using json2.js and I am trying to serialize x in a string. and all I get is the array: [1,2,3,4]
is that correct ? since I can add any property to an array why doesn't json2 handle that ? what am I missing ?
Let's imagine we come out with something like:
[1,2,3,4]{name:'test',anotherProperty:'someValue'}
if the above was valid javascript to create an array and stick two properties then it would be great and we could json-it. It would be equivalent to do this:
array = [1,2,3,4]
array.name = 'test';
array.anotherProperty = 'someValue';
But it is not and that's the reason why we can not persist into json.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With