您不应该将 JSON 传递到内部 JavaScript 库中。您应该将 JSON 解析为 JS 对象,然后对其进行迭代,将其转换为新格式
例子
var json = '[{"a": 1:, "b": 2}, {"a": 4:, "b": 5}]';
var jsObj = JSON.parse(json);
// Transform property a into aa and property b into bb
var transformed = jsObj.map(function(obj){
return {
aa: obj.a,
bb: obj.b
}
});
// transformed = [{aa:1, bb:2},{aa:4, bb:5}]
If you really want JSON you'd just call JSON.stringify(transformed)
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/map
这是另一个更复杂转换的答案如何用标准 json 制作 jquery Datatable 数组?