JoltTransform convert to string

Viewed 140

I am strugling a bit with my JoltTransform. I just need to convert the decimal characters to string, but for the life of me I cannot get it to work, as per the example it would be the policy_revision_no and the policy_endorsement_no ..

My example json file I am using is:

{
  "policy_unique_reference": "TST1",
  "item_unique_reference": "TST2",
  "item_parent_item_unique_reference": "",
  "item_type": "Cover",
  "item_parent_section": "Stuff",
  "item_subsection_extension": "",
  "policy_revision_no": 1,
  "policy_endorsement_no": 2
}

My current Jolt Transform is:

[
 {
  "operation": "shift",
  "spec": {
    "*": "Items.&"
  }
 }, 
 {
  "operation": "modify-overwrite-beta",
  "spec": {
    "*": {
      "Items": {
        "policy_revision_no": "=toString"
      }
    }
  }
 }
]

My current result that I am getting is:

{
  "Items" : {
    "policy_unique_reference" : "TST1",
    "item_unique_reference" : "TST2",
    "item_parent_item_unique_reference" : "",
    "item_type" : "Cover",
    "item_parent_section" : "Stuff",
    "item_subsection_extension" : "",
    "policy_revision_no" : 1,
    "policy_endorsement_no" : 2,
    "Items" : { }
  }
}

Thank you.

1 Answers

You can directly apply modify transform such as

[
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "policy_*": "=toString"
    }
  }
]

presumingly you need to apply for the elements with keys starting with policy_

enter image description here

Related