I have a REST API from which i am fetching the json data and storing them in array.(我有一个REST API,可从中获取json数据并将其存储在数组中。)
The API looks like below:(该API如下所示:)
[
{
"id": "100",
"name": "Person1",
"number": "+91-8980439023"
},
{
"id": "102",
"name": "Person2",
"number": "+91-5980339023"
},
{
"id": "105",
"name": "Person3",
"number": "+91-8980439023"
},
{
"id": "101",
"name": "Person4",
"number": "+91-8980439023",
"parent": "105"
},
{
"id": "110",
"name": "Person5",
"number": "+91-8980439023"
},
{
"id": "115",
"name": "Person6",
"number": "+91-9834295899",
"parent": "100"
}
]
Some of the data have "parent" field.The value in the "parent" field is the "id" of the other data.(某些数据具有“父”字段。“父”字段中的值是其他数据的“ id”。) Now i want to store these data which have reference in the "parent" field of other data in a separate array.(现在,我想将在其他数据的“父”字段中引用的这些数据存储在单独的数组中。) For example: The data with id=101 has "parent" key with value 105 which in turn is the id of the 3rd data.So the data with id=105 should be stored in separate array.(例如:id = 101的数据具有“ parent”键,其值为105,这又是第三数据的id。因此id = 105的数据应存储在单独的数组中。)
How can i do in a simple and scalable way?(如何以简单且可扩展的方式进行操作?)
ask by Pawan Patel translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…