【发布时间】:2021-02-19 18:38:44
【问题描述】:
大家好,我有情况需要你的帮助,我有一个具有公共 id 的 json 数组,首先我需要从所有 json obj 中获取公共 id,然后将每个公共 json 放置到单独的数组中
var myArray = [ {"id" : 1, "text": "Number one", "time": "16 03 13"},{"id" : 1, "text": "Number two", "time": "14 03 13"},{"id" : 1, "text": "Number three", "time": "13 03 13"},{"id" : 2, "text": "Number one", "time": "13 03 13"}]
I want output of this object as
var myArray = {
[
"1" : [
{"text": "Number one", "time": "16 03 13"},
{"text": "Number two", "time": "14 03 13"},
{"text": "Number three", "time": "13 03 13"}
]
]
[
"2" : [
{"text": "Number one", "time": "13 03 13"}
]
]}
I want to place common ID in a each separate JSON array to make 2d array
【问题讨论】:
标签: javascript node.js json arraylist