I have a string as shown below
[{ date: new Date(2015,9,25), NAV: 12},{ date: new Date(2016,9,25), NAV: 22}]
how can i convert that to object array using jQuery?
由于new Date(2015,9,25)
不是有效的JSON,因此您需要使用eval(yourString)
将字符串解析为有效的Object:
console.log(eval('[{ date: new Date(2015,9,25), NAV: 12},{ date: new Date(2016,9,25), NAV: 22}]'));
You can convert to a valid Javascript object using function
JSON.parse(str);
but string should be in valid json format.
try this,
var obj = $.parseJSON(jsonString);
or
var obj = jQuery.parseJSON(jsonString);
may be this might help
you can convert it to json.parse:
var json = $.parseJSON(myString)
or you can refer this link below
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.