Associative Array does not work with eval() JavaScript
Question: I am generating a data expressed as a Python dictionary which is dumped using
simplejson via url which is in this format.

    
    
    {"2": "London", "3": "Tokyo", "4": "Sydney"}
    

I am using `$.get` and storing into a variable data. However `eval(data)` does
not generate an Associative Array. Actually throws up an error. What is the
problem? What is the solution?

Edit: I have shared the code <http://dpaste.com/570901/>


Answer: We need to see more code...

    
    
    var x = '{"2": "London", "3": "Tokyo", "4": "Sydney"}';
    
    eval('var y = ' + x);
          // or
    var y = eval('(' + x + ')');
    
    console.log(y);
    console.log(y["2"]);
    

The above works just fine. What exactly are you doing/not doing?

PS: You shouldn't use `eval` for this regardless, but it's important to know
how it works.

