【发布时间】:2019-04-03 17:38:48
【问题描述】:
我有下一个 JSON
{
"updated": [
{
"id": "1",
"email": "api.test@test.io",
"businessUnit": "US",
"firstName": "John",
"lastName": "Doe",
"age": 21,
"gender": "male"
},
{
"id": "2",
"email": "api.test@test.io",
"businessUnit": "US",
"firstName": "John",
"lastName": "Doe",
"age": 22,
"gender": "male"
},
{
"id": "3",
"email": "api.test@test.io",
"businessUnit": "US",
"firstName": "John",
"lastName": "Doe",
"age": 23,
"gender": "male"
}
],
"deleted": [
{
"id": "4",
"email": "api.test@test.io",
"businessUnit": "US",
"firstName": "John",
"lastName": "Doe",
"age": 31,
"gender": "male"
},
{
"id": "5",
"email": "api.test@test.io",
"businessUnit": "US",
"firstName": "John",
"lastName": "Doe",
"age": 32,
"gender": "male"
},
{
"id": "6",
"email": "api.test@test.io",
"businessUnit": "US",
"firstName": "John",
"lastName": "Doe",
"age": 33,
"gender": "male"
}
]
}
-
是否可以通过其他方式更改“id”文件,而不是:
- 设置 req.updated[0].id = userId
- 设置 req.updated[1].id = userId
- 设置 req.updated[2].id = userId
-
是否可以更改“已更新”和“已删除”两个部分中的所有“id”文件,例如:
- 设置 req[*].id = userId
【问题讨论】: