【发布时间】:2019-05-21 05:40:49
【问题描述】:
我有以下对象数组:
[
{
"userId": 1,
"id": 1,
"title": "delectus aut",
"completed": false
},
{
"userId": 1,
"id": 2,
"title": "quis ut",
"completed": false
}
]
我想要以下输出:
userId | id | title | completed |
1 | 1 | delectus aut| false |
1 | 2 | quis ut | false |
我尝试过使用 lodash ,但考虑到循环的数量,我觉得我们有比这更好的解决方案:
jsonObject = response; // consider the above mention object here.
keys = _.keys(json[0]);
我发现json[0] 在所有情况下都不会相同,那么找到解决方案的最佳方法是什么。
任何帮助将不胜感激!!!
【问题讨论】: