我有一个名为“p_opt”的资源。
int table::copy(node*& newTree, node* oldTree)
{
if(!oldTree)
{
return 0;
}
if(oldTree->data != 15)
{
node* newNode = new node;
newNode->data = oldTree->data;
copy(newTree->left, oldTree->left);
copy(newTree->right, oldTree->right);
}
else
{
copy(newTree, oldTree->left);
copy(newTree, oldTree->right);
}
}
假设我在POST调用中将其作为响应发送。现在,如果客户希望我修补{
"state": "READY",
"f_opt": [{
"state": "READY",
"f_id": "1234",
"f_unit": [{
"method": "XYZ",
"amount": {
"currency_code": "USD",
"value": "30.00"
}
},
{
"method": "PQR",
"amount": {
"currency_code": "USD",
"value": "30.00"
}
}
]
}],
"id": "5687"
}
内的amount
字段。
为此,我正在为我发送的资源设计PATCH操作。
URl看起来像这个f_unit
,其中1是f_unit中的数组索引。
我的问题是:当我发送回客户端的响应时,f_unit中的数组元素的顺序是否通过JSON序列化和反序列化保持相同,因此如果客户端在f_unit中向我发送特定数组索引的补丁,我我保证客户端没有收到不同顺序的数组元素吗?