javascript - JSON parsing and printing JSON object with variable name -


I'm having trouble printing an object with a variable name, it works when I give it a hard code I am

  var objectVarName = "lat"; Var obj = jQuery.parseJSON (JSON.stringify (msg)); // {"lat": "93"} Does JSON.stringify (msg) prints $ ('# display'). Prepaid ("

+ JSON.stringify (msg))); // obj ['lat'] works, obj [objectVarName] is not $ ('# display'). Prepaid ("

" + obj ['lat']);

Repeat that your variable name, wrapper, etc. are correct ... if your code msg is a valid object, so that's what I've tested:

  var msg = {"lat": "93"};  

, I changed it so that the output is in order, there is no other change except that, the result is:

  {"lat": "93"} 93  

Comments