gpt4 book ai didi

javascript - 如何将命名 json 数组转换为未命名数组

转载 作者:行者123 更新时间:2023-12-02 15:42:41 25 4
gpt4 key购买 nike

我需要转换以下 json 数组

{
"employees": [{
"firstName": "John",
"lastName": "Doe"
}, {
"firstName": "Anna",
"lastName": "Smith"
}, {
"firstName": "Peter",
"lastName": "Jones"
}]
}

到一个没有名称“Employee”的 json 数组

 {[
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":"Smith"},
{"firstName":"Peter", "lastName":"Jones"}
]}

使用 JavaScript

最佳答案

试试这个

var employeeArr =  {"employees":[
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":"Smith"},
{"firstName":"Peter", "lastName":"Jones"}
]}

var emp = $.each(employeeArr.employees, function(index , value){
return value;
},{})

console.log(emp);

关于javascript - 如何将命名 json 数组转换为未命名数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32449414/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com