我尝试了JSON.parse
,但没有成功。请告诉我如何解析这些数据。
[
{
"value": { "top": 343,"left": 397,"width": 283,"height": 283} ,
"main": {"sm": 0.263,"sd": 5,"fs": 22,"gs": 15}
}
]
我的目标是使用obj.x来访问对象:
obj = JSON.parse(data);
$( "#dialog_title_span" ).text(obj.value.top + obj.value.left);
编辑:Json更正。
答案 0 :(得分:-1)
This is not a jSON. It is just an array of objects. You can traverse through loop. Like data[0].value.top gives you 343.
JSON is
Data is in name/value pairs, Data is separated by commas, Curly braces hold objects,
like:-
var value = '{ "name":"John", "age":30, "city":"New York"}'
This is a JSON. you can parse it using JSON.parse
a = JSON.parse(value)
Then you can acces name like:-
a.name
For more refernce you can study here