Add Value to every List Entry
Pytry opened this issue · 2 comments
Pytry commented
Given The Input:
{
"rate": 3.5,
"items": [
{
"a": "a1",
"b": "b1"
},
{
"a": "a2",
"b": "b2"
}
]
}
The output should be:
{
"results" : [
{
"a" : "a1",
"b" : "b1",
"RATE" : 3.5
},
{
"a" : "a2",
"b" : "b2",
"RATE" : 3.5
}
]
}
My current chain is:
[
{
"operation": "shift",
"spec": {
"items": {
"*": {
"a": "results[&1].a",
"b": "results[&1].b",
"&3.rate": "results[&1].RATE"
}
}
}
}
]
The intent of "&3.rate" was to traverse back to the root andis to grab the value of a field off of the root.
The number of entries in "items" cannot be known before hand.
Is there a way to accomplish this?
bobeal commented
You have to use the @
operator instead:
[
{
"operation": "shift",
"spec": {
"items": {
"*": {
"a": "results[&1].a",
"b": "results[&1].b",
"@(2,rate)": "results[&1].RATE"
}
}
}
}
]
Pytry commented
You have to use the
@
operator instead:
It worked! I could of sworn I tried that already:P Thank you so much for the help:)