Options
- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Solved
Go to solution
Jolt-JSON Transformation
Labels:
- Labels:
-
Apache NiFi
Explorer
Created ‎03-02-2022 12:03 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Super Guru
Created ‎03-02-2022 04:57 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@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.
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.
2 REPLIES 2
Super Guru
Created ‎03-02-2022 04:57 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@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.
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.
Explorer
Created ‎03-07-2022 03:52 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
{
"_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?
