如何把 json对象转换成 数组
json
适用于现代 C++ 的 JSON。
项目地址:https://gitcode.com/gh_mirrors/js/json

·
// var data2 = JSON.parse(data); // JSON.parse() 把 json字符串 转化成 json 对象 // var a = JSON.stringify(data); //把json对象转化成字符串 // 如何把 json对象转换成 数组 // 参考网址 https://www.cnblogs.com/wancheng7/p/8735168.html // data 是原json对象,data2 是想转成的数组 var data2 = []; // 某种意义上来说,数组也是object for (let i in data) { let o = {}; o[i] = data[i]; data2.push(o) }
// var data2 = JSON.parse(data); // JSON.parse() 把 json字符串 转化成 json 对象
// var a = JSON.stringify(data); //把json对象转化成字符串
// 如何把 json对象转换成 数组
// 参考网址 https://www.cnblogs.com/wancheng7/p/8735168.html
// data 是原json对象,data2 是想转成的数组
var data2 = []; // 某种意义上来说,数组也是object
for (let i in data) {
let o = {};
o[i] = data[i];
data2.push(o)
}




适用于现代 C++ 的 JSON。
最近提交(Master分支:6 个月前 )
c67d5382
* :alembic: try matrix for latest
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
* :recycle: refactor from https://github.com/nlohmann/json/issues/4745#issuecomment-2810128420
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
* :construction_worker: simplify CI
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
* :construction_worker: simplify CI
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
* :rotating_light: fix cpplint warning
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
* :construction_worker: simplify CI
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
---------
Signed-off-by: Niels Lohmann <mail@nlohmann.me> 3 天前
88c92e60
* :rotating_light: fix warnings
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
* :rotating_light: fix warnings
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
* :alembic: enable ranges support
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
* :fire: remove ci_nvhpc job
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
* :alembic: enable ranges support
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
* :fire: remove ci_nvhpc job
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
* :rotating_light: fix warning
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
---------
Signed-off-by: Niels Lohmann <mail@nlohmann.me> 5 天前
更多推荐
所有评论(0)