Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Jolt-JSON Transformation

avatar
Explorer
I want to transform this JSON:
{
  "_id" : "6218e53465793fa20ea11524",
  "patientorderitems" : [ {
    "poi_id" : "6218e53465793fa20ea1152a",
    "patientorderlogs" : [ {
      "pol_id" : "6218e53465793fa20ea1152e",
      "useruid" : "61ee4995f16eebb6b7e1c644",
      "modifiedat" : "2022-02-25T17:18:28Z"
    } ]
  }, {
    "poi_id" : "6218e53465793fa20ea11525",
    "patientorderlogs" : [ {
      "pol_id" : "6218e53465793fa20ea11529",
      "useruid" : "61ee4995f16eebb6b7e1c644",
      "modifiedat" : "2022-02-25T17:18:28Z"
    } ]
  } ]
}
To this JSON:
 
{
{
 "_id" : "6218e53465793fa20ea11524",
 "poi_id" : "6218e53465793fa20ea1152a",
 "pol_id" : "6218e53465793fa20ea1152e",
 "useruid" : "61ee4995f16eebb6b7e1c644",
 "modifiedat" : "2022-02-25T17:18:28Z"
},
{
 "poi_id" : "6218e53465793fa20ea11524",
 "poi_id" : "6218e53465793fa20ea11525",
 "pol_id" : "6218e53465793fa20ea11529",
 "useruid" : "61ee4995f16eebb6b7e1c644",
 "modifiedat" : "2022-02-25T17:18:28Z"
}

}
 
Is there any Jolt format or scripts can do this?
1 ACCEPTED SOLUTION

avatar
Super Guru

@Asim- ,

 

Try this one out:

[
  {
    "operation": "shift",
    "spec": {
      "patientorderitems": {
        "*": {
          "patientorderlogs": {
            "*": {
              "@(4,_id)": "[&3]._id",
              "@(2,poi_id)": "[&3].poi_id",
              "pol_id": "[&3].pol_id",
              "useruid": "[&3].useruid",
              "modifiedat": "[&3].modifiedat"
            }
          }
        }
      }
    }
  }
]

 

Cheers,

André

 

--
Was your question answered? Please take some time to click on "Accept as Solution" below this post.
If you find a reply useful, say thanks by clicking on the thumbs up button.

View solution in original post

2 REPLIES 2

avatar
Super Guru

@Asim- ,

 

Try this one out:

[
  {
    "operation": "shift",
    "spec": {
      "patientorderitems": {
        "*": {
          "patientorderlogs": {
            "*": {
              "@(4,_id)": "[&3]._id",
              "@(2,poi_id)": "[&3].poi_id",
              "pol_id": "[&3].pol_id",
              "useruid": "[&3].useruid",
              "modifiedat": "[&3].modifiedat"
            }
          }
        }
      }
    }
  }
]

 

Cheers,

André

 

--
Was your question answered? Please take some time to click on "Accept as Solution" below this post.
If you find a reply useful, say thanks by clicking on the thumbs up button.

avatar
Explorer
{
  "_id": "620e6275034f4fe64f1ce2ef",
  "patientorderitems": [
    {
      "_id": "620e6275034f4fe64f1ce2f0",
      "patientorderlogs": [
        {
          "_id": "620e6275034f4fe64f1ce2f1",
          "useruid": "6031edd256afd66888232d6e",
          "departmentuid": "602f6a3494ce862c04aa49d2"
        },
        {
          "_id": "621efc35da15edd34560da80",
          "useruid": "6032021359f2cf686ae807ba",
          "departmentuid": "602f6a3494ce862c04aa49d5"
        },
        {
          "_id": "6220a702061f33f4abe8a2a6",
          "useruid": "604f3cb743027274a8c565de",
          "departmentuid": "604c5393864aa9012d79e986"
        },
        {
          "_id": "6220a70f65ca50f522598a85",
          "useruid": "604f3cb743027274a8c565de",
          "departmentuid": "604c5393864aa9012d79e986"
        },
        {
          "_id": "6220a717145139f53cfb6143",
          "useruid": "604f3cb743027274a8c565de",
          "departmentuid": "604c5393864aa9012d79e986"
        }
      ]
    }
  ]
}

dear araujo

can I have a jolt specification for this JSON as the same format of last JSON?