我有一个类似下面的JSON文件,我想将它消毒到JSON对象我该怎么办?谢谢
{
"TOTAL": 2,
"PRODUCTS": [
{
"CODE": "T55",
"PRICE": 59.95,
"DESCRIPTION": "Ok"
},
{
"CODE": "T75",
"PRICE": 99.95,
"DESCRIPTION": "Not OK"
}]
答案 0 :(得分:0)
您可以引用此链接进行文件解析: Get a JSON file from URL and display
和强>
您可以使用: var obj = JSON.parse(' {" name":" Pawan"," age":24}');
答案 1 :(得分:0)
现代浏览器支持JSON.parse()。
var json = [{
"TOTAL": 2,
"PRODUCTS": [
{
"CODE": "T55",
"PRICE": 59.95,
"DESCRIPTION": "Ok"
},
{
"CODE": "T75",
"PRICE": 99.95,
"DESCRIPTION": "Not OK"
}];
var arr_from_json = JSON.parse( json_string );
在不适合的浏览器中,您可以包含json2库。