输入json:
{
"accountType": "Admin",
"id": "aaab-ccc-ddd-eeeAAA",
"relationship": "DIRECT",
"accountInfo": {
"partyTypeCode": "PARTNER",
"source": "Facebbok",
"internalAccount": true,
"category": "Father"
}
}
输出:
{
"key":"aaab-ccc-ddd-eeeAAA~Admin",
"relationship":"aaab-ccc-ddd-eeeAAA~Admin~0001"
}
这里
0001
是Father的相应代码
第二个场景, 输入 JSON:
{
"accountType": "User",
"id": "aaab-ccc-ddd-eeeAAA",
"relationship": "DIRECT",
"accountInfo": {
"partyTypeCode": "PARTNER",
"source": "Facebbok",
"internalAccount": true,
"category": "Father"
}
}
输出:
{
"key":"aaab-ccc-ddd-eeeAAA",
"relationship":"aaab-ccc-ddd-eeeAAA~0001"
}
仅当管理员应附加时,键才不应包含附加。但 0001 应该附加到关系
输出1:
{
"key":"aaab-ccc-ddd-eeeAAA~Admin",
"relationship":"aaab-ccc-ddd-eeeAAA~Admin~0001"
}
输出2:
{
"key":"aaab-ccc-ddd-eeeAAA",
"relationship":"aaab-ccc-ddd-eeeAAA~0001"
}
您可以使用以下转换
[
{ // conditional for the cases of "accountType" values
"operation": "shift",
"spec": {
"accountType": {
"Admin": {
"@2,id|$": "key"
},
"*": {
"@2,id": "key[]"
}
},
"@accountInfo.category": "rel" // assign a new attribute for this value
}
},
{ // conditional for the cases of "accountInfo.category" values
"operation": "shift",
"spec": {
"*": "&",
"rel": {
"Father": {
"#~0001": "&2"
},
"*": {
"# ": "&2"
}
}
}
},
{ // generate "relationship" attribute
"operation": "modify-overwrite-beta",
"spec": {
"key": "=join(~,@(1,&))",
"rel": "=concat(@(1,key),@(1,rel))",
"relationship": "=trim(@(1,rel))" // remove trailing whitespace if exists
}
},
{ // get rid of the auxiliary attribute "rel"
"operation": "remove",
"spec": {
"rel": ""
}
}
]