假设您有以下 JSON:
{"zero":{"0":"foo","1":"foo2"},"one":"fooa","two":"foob"}
将其转换为的最有效方法是什么:
var zero = ['foo','foo2'];
var one = 'fooa';
var two = 'foob';
假设您有以下 JSON:
{"zero":{"0":"foo","1":"foo2"},"one":"fooa","two":"foob"}
将其转换为的最有效方法是什么:
var zero = ['foo','foo2'];
var one = 'fooa';
var two = 'foob';
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;