如何从此Json结果或响应中选择一些字段 哪个有打击格式
var WPQ3ListData = { "Row" :
[{
"ID": "27",
"PermMask": "0x400001f07fff1bff",
"FSObjType": "0",
"Title": "NOOO",
"FileLeafRef": "27_.000",
"TotalCost": "87",
"TotalCost.": "87.0000000000000",
"TC1ID": "23",
"TotalCost.SUM": "160"
}]
}
例如,我想选择TotalCost.SUM值并将其存储到变量中 在jQuery的document.ready上
答案 0 :(得分:3)
您可以使用WPQ3ListData.row[0]["TotalCost.SUM"]
var WPQ3ListData = { "Row" :
[{
"ID": "27",
"PermMask": "0x400001f07fff1bff",
"FSObjType": "0",
"Title": "NOOO",
"FileLeafRef": "27_.000",
"TotalCost": "87",
"TotalCost.": "87.0000000000000",
"TC1ID": "23",
"TotalCost.SUM": "160"
}]
};
$(document).ready(function(){
var valueReq = WPQ3ListData.Row[0]["TotalCost.SUM"];
});
答案 1 :(得分:0)
应该使用关联数组索引,即object [“property”]
var WPQ3ListData = { "Row" :
[{
"ID": "27",
"PermMask": "0x400001f07fff1bff",
"FSObjType": "0",
"Title": "NOOO",
"FileLeafRef": "27_.000",
"TotalCost": "87",
"TotalCost.": "87.0000000000000",
"TC1ID": "23",
"TotalCost.SUM": "160"
}]
}
$(document).ready(function(){
var value = WPQ3ListData.Row[0]["TotalCost.SUM"];
});
答案 2 :(得分:0)
`WPQ3ListData.Row[0]["TotalCost.SUM"]`
var WPQ3ListData = { "Row" :
[{
"ID": "27",
"PermMask": "0x400001f07fff1bff",
"FSObjType": "0",
"Title": "NOOO",
"FileLeafRef": "27_.000",
"TotalCost": "87",
"TotalCost.": "87.0000000000000",
"TC1ID": "23",
"TotalCost.SUM": "160"
}]
};
$(document).ready(function(){
var requestValue = WPQ3ListData.Row[0]["TotalCost.SUM"];
});