Home > Mobile >  Rearrange "DistributedAmount" field in JOLT
Rearrange "DistributedAmount" field in JOLT

Time:12-26

In JOLT I am trying to rearrange distributed amount field. However, itemTotalAmount is getting sorted correctly in the output but distributedAmount is not.

Any idea what changes I need to make to the JOLT spec to get the distributedAmount field in the output?

Link for Input and Spec- enter image description here

CodePudding user response:

Your Jolt spec file is about 490 lines!!!

This answer is not a good answer.

But I suggest you do all of your transformations and when it's done, see again your spec and try to optimize your spec. For example, In your case, you can merge some of your shift operations together.

The simple and fastest way to achieve your desired output is adding a new spec to your current spec.

Please add the below spec to your current spec:

,
  {
    "operation": "shift",
    "spec": {
      "*": { // IntegrationDetails
        "*": { // integrationEntities
          "*": { // integrationEntity
            "*": { // 0
              "integrationEntityHeader": "&4.&3.&2[&1].&",
              "integrationEntityDetails": {
                "*": { // poDetails
                  "*": "&6.&5.&4[&3].&2.&1.&",
                  "items": {
                    "item": {
                      "*": "&8.&7.&6[&5].&4.&3.&2.&1.&",
                      "validCombinations": {
                        "*": { // itemDetails
                          "validRules": "&10.&9.&8[&7].&6.&5.&4.&3.&2.&1.&",
                          "distributedAmount": "&10.&9.&8[&7].&6.&5.&4.&3.&2.&1.&"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  • Related