Fastest way to split a string into a multidimensional array of arbitrary dimensions in JavaScript?

I'm trying to determine the fastest way to split a string in JavaScript into a multidimensional array with arbitary dimensions. Is there a way better than looping over the string and matching brackets of the same depth?

Example string:



If you don't need to count for older browsers, you can use JSON.parse:

var a = '[1,2,3,[1,2,3,[1,2,3]],4,5,[1,2],[[1,2],[1,2]],[1],[1]]';

var b = JSON.parse(a);

For older browsers I can think of one quick and dirty way, some use it as last resort of parsing JSON.

var a = '[1,2,3,[1,2,3,[1,2,3]],4,5,[1,2],[[1,2],[1,2]],[1],[1]]';

var b = (new Function('return ' + a + ';'))();

Need Your Help

Parsing complex JSON

json parsing windows-phone-7 windows-phone-7.1

I want to parse a complex JSON on WP7. First I have to parse a JSON feed and I retrieve data to parse second JSON feed.

Cannot run node-redis-session lib

node.js session cookies redis

I've installed the node-redis-session dependency and in the first time runs fine, but i've deleted the created cookies of the browser, and now I cannot make it run again.