Open mllenz opened 3 years ago
Fala maikon de boa. Olha a solução ai.
[
{
"operation": "shift",
"spec": {
"dict": "dict",
"list": {
"*": {
"ref": {
"*": {
"@1": "list[&3].ref",
"@(4,dict.&0)": "list[&3].orig"
}
},
"*": "list[&1].&0"
}
}
}
}
]
Hi, I have a list of entities with some unique id and unique reference. But I need to insert the value of a dictionary (in a field named orig) matching the key of that dictionary with ref field of the list. When the key isn't found inside the list, the orig can be null. This is the input:
{ "dict": { "F": "3", "A": "6", "G": "7" }, "list": [ { "id": 5, "ref": "A" }, { "id": 3, "ref": "G" }, { "id": 2, "ref": "F" }, { "id": 7, "ref": "F" } ] }
And this is the output that I want:
{ "dict": { "F": "3", "A": "6", "G": "7" }, "list": [ { "id": 5, "ref": "A", "orig": "6" }, { "id": 3, "ref": "G", "orig": "7" }, { "id": 2, "ref": "F", "orig": "3" }, { "id": 7, "ref": "F", "orig": null } ] }