1

假设您有以下 JSON:

{"zero":{"0":"foo","1":"foo2"},"one":"fooa","two":"foob"}

将其转换为的最有效方法是什么:

 var zero = ['foo','foo2'];
 var one = 'fooa';
 var two = 'foob';
4

1 回答 1

3

JSON .解析:

var json = '{"zero":{"0":"foo","1":"foo2"},"one":"fooa","two":"foob"}';
var pJson = JSON.parse(json);
var zero = [ pJson.zero[0], pJson.zero[1] ];
var one = pJson.one;
var two = pJson.two;
于 2012-10-19T22:31:19.587 回答