I am receiving a JSON string from an ajax call and would like to convert a value to a predefined variable:
var predefined = \"hello world\"; var foo = {\"msg
var out = eval(foo.msg); // out is now "hello world"
Note: do not use eval() if you are not sure what the content of foo.msg is.
eval()
foo.msg
or
var out = foo.msg=="predefined" ? predefined : foo.msg;