i have this object:
"{"logEntries":[],"value":"-8","text":"Europe","enabled":true}"
how do i get the value of the "value" key in jQuery with minimum code?. in this case "-8".
i have this object:
"{"logEntries":[],"value":"-8","text":"Europe","enabled":true}"
how do i get the value of the "value" key in jQuery with minimum code?. in this case "-8".
var obj = '{"logEntries":[],"value":"-8","text":"Europe","enabled":true}';
obj = $.parseJSON(obj);
console.log(obj.value);
You had double quotes inside double quotes, you can't do that, you need to wrap it in single quotes.
Also, you don't need the quotes here in the first place, just make an object, not a string, so you don't to parse.
var obj = {"logEntries":[],"value":"-8","text":"Europe","enabled":true};
console.log(obj.value);
    I suggest :
var myObject = '{"logEntries":[], "value":"-8", "text":"Europe", "enabled":true}';
alert($.parseJSON(myObject).value);