05/04/2014 09:09 keltezéssel, jarous92 írta:
> Hello,
> I have JSON string:
>
> var Jstring = "{"1":1,"2":2}";
>
> I need to convert the Jstring to JavaScript array like this: var array =
> [1,2];
>
> I try this, but unsuccessfully:
>
> var array = JSON.parse(Jstring);
>
Well, you see, that JSON string is the object { "1": 1, "2": 2 }, which
is very different from an array with two elements. If anything, arrays
are indexed from 0 (not from 1).
Two, I don't think what you wrote above is valid JavaScript syntax. You
probably mean
var Jstring = "{\"1\": 1, \"2\": 2}";
That's indeed parseable with JSON and the result is an object with two
keys ("1" and "2"), each holding a number value (1 and 2, respectively).
------------------------------------------------------------------------------
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel