我在我的nodejs应用程序中有一个供应商API调用,它返回各种对象,下面是JSON中一个对象的示例:
[{
"id": 365467865567,
"type": "PERSON",
"created_time": 1492809120,
"updated_time": 1492809542,
"last_contacted": 1492809128,
"properties": [
{
"type": "SYSTEM",
"name": "phone",
"value": "123456789"
},
{
"type": "SYSTEM",
"name": "first_name",
"value": "Test2"
},
{
"type": "SYSTEM",
"name": "last_name",
"value": "You"
},
{
"type": "CUSTOM",
"name": "utm_medium",
"value": "email"
}
]
}]
使用此格式的数据并不容易,需要将其转换为键值格式。类似于:
[{
"id": 365467865567,
"type": "PERSON",
"created_time": 1492809120,
"updated_time": 1492809542,
"last_contacted": 1492809128,
"properties":
{
"phone": "123456789",
"first_name": "Test2",
"last_name": "You",
"utm_medium": "email"
}
}]
改变这种情况的最有效方法是什么?