Austin,
This one works for your sample data but doesn't extend to more fields
unless you keep repeating the pattern in the spec:
[
{
"operation": "shift",
"spec": {
"@Place1": "TestArray[0].Place",
"@Holder1": "TestArray[0].Holder",
"@Place2": "TestArray[1].Place",
"@Holder2": "TestArray[1].Holder"
}
}
]
Basically I don't know of a way to get the "1" from "Place1" into a
index that can be used in the target.
Regards,
Matt
On Tue, Feb 13, 2018 at 5:32 PM, Austin Duncan <[email protected]> wrote:
> All, I am trying to transfrom a json. I want the final to look like:
> "TestArray": [{
> "Place": "Test1",
> "Holder": "Test2"
> },
> {
> "Place": "Test3",
> "Holder": "Test4"
> }
> My source Json is flat with these specs:
> "Place1" : "Test1",
> "Holder1" : "Test2",
> "Place2" : "Test3",
> "Holder2" : "Test4"
>
> With this transform:
>
> [
> {
> "operation": "shift",
> "spec": {
> "@Place1": "TestArray[].Place",
> "@Holder1": "TestArray[].Holder",
> "@Place2": "TestArray[].Place",
> "@Holder2": "TestArray[].Holder"
> }
> }
> ]
>
> I get the following result:
>
> {
> "TestArray" : [ {
> "Payer" : "Test1"
> }, {
> "PolicyNumber" : "Test2"
> }, {
> "Payer" : "Test3"
> }, {
> "PolicyNumber" : "Test4"
> } ]
> }
>
> Does anyone have any insight as to how to fix my problem? I am at a loss
> here and Am not quite sure where to go.
>