【发布时间】:2016-08-19 20:27:08
【问题描述】:
我正在尝试从 json 结构中获取特定键的特定 json 值。我尝试了以下方法:
var jsonstring;
jsonstring = JSON.stringify(myjsonObjectArray);
alert(jsonstring);//giving the below json structure
jsonstring = [{
"key01": [10, "Key01 Description"],
"key02": [false, "It's a false value"],
"key03": [null, "Testing Null"],
"key04": ["tests", "Another Test Value"],
"key05": [
[25, 50], "Some testing values"
]
}, {
"key10": [100, "Key10 Value"],
"key11": [true, "It's a true value for key11"],
"key12": [null, "key12 values is Null"],
"key13": ["Testing", "Another Test Value for key13"],
"key14": [
[10, 20], "Some other testing values"
],
"key15": ["Test Name", "Name of the key15"]
}]
但我需要如下结构:
jsonstring = [{
"key01": 10,
"key02": false,
"key03": null,
"key04": "tests",
"key05": [25, 50]
}, {
"key10": 100,
"key11": true,
"key12": null,
"key13": "Testing",
"key14": [10, 20],
"key15": "Test Name"
}]
我怎样才能得到上面的结构(意味着我只需要单个值,不需要结构中各个键的第二个值/多个值)?请帮助我并提前致谢。
【问题讨论】:
-
这不是coffeescript ;)
标签: javascript jquery angularjs json coffeescript