Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Support Questions

Find answers, ask questions, and share your expertise
Announcements
Share your experience with Cloudera on G2 and get a $25 Amazon Gift card.
Hi, I'm CLEO! Something exciting is coming to the Community. Stay Tuned!

JOLT Transformation: Moving Child name value to parent denormalize

avatar
Rising Star

For the below given input, how do i move the name value pairs(installDate and status) to the upper level

{
"header": {
"version": "1.0",
"timeStamp": "1670484663189",
"activityId": "256388257993155783",
"action": "create",
"refreshId": "null"
},
"resource": {
"drniId": "256383859946641699",
"@type": "LogicalCrossConnection",
"subtype": "Backplane Connection",
"name": "Backplane Connection",
"resourceCharacteristic": [
{
"name": "tmf639_dataSource_ingestion_uuid",
"value": "256383859946641699",
"@type": "string"
},
{
"name": "p16Latest",
"value": true,
"@type": "boolean"
},
{
"name": "installDate",
"value": "202303323",
"@type": "string"
},
{
"name": "status",
"value": "In Service",
"@type": "string"
}
],
"resourceRelationship": [
{
"drniId": "256387639517862117",
"@type": "LogicalInterface:HAS_CONNECTION_COMPONENT:OUT",
"subtype": "ODU2e",
"name": "ODU2e.1-8",
"relationDrniId": "256383859946641700",
"resourceRelationshipCharacteristic": [
{
"name": "p16Latest",
"value": true,
"@type": "boolean"
},
{
"name": "sectionNumber",
"value": 0,
"@type": "long"
},
{
"name": "p3CreateActivity",
"value": 256388257993155780,
"@type": "long"
},
{
"name": "isNotInRoute",
"value": "N",
"@type": "string"
},
{
"name": "p2Create",
"value": 1670480203578,
"@type": "long"
},
{
"name": "seq",
"value": 1,
"@type": "long"
}
]
},
{
"drniId": "256383859946641335",
"@type": "LogicalInterface:HAS_CONNECTION_COMPONENT:OUT",
"subtype": "ODU2e",
"name": "ODU2e.1-8",
"relationDrniId": "256383859946641701",
"resourceRelationshipCharacteristic": [
{
"name": "p16Latest",
"value": true,
"@type": "boolean"
},
{
"name": "sectionNumber",
"value": 0,
"@type": "long"
},
{
"name": "p3CreateActivity",
"value": 256388257993155780,
"@type": "long"
},
{
"name": "isNotInRoute",
"value": "N",
"@type": "string"
},
{
"name": "latest",
"value": [
2,
3,
16
],
"@type": "array"
}

]
}
]
}
}

 

 

Expected Output

{
"records" : {
"inv_activity_ts" : "1670484663189",
"inv_activity_id" : "256388257993155783",
"action" : "create",
"inv_id" : "256383859946641699",
"inv_subtype" : "Backplane Connection",
"inv_name" : "Backplane Connection",
"installDate" : "202303323",
"status" : "status"
}
}

@SAMSAL Any help you could provide?

3 REPLIES 3

avatar
Super Guru

Hi,

See if this helps:

 

[
  {
    "operation": "shift",
    "spec": {
      "header": {
        "timeStamp": "records.inv_activity_ts",
        "activityId": "records.inv_activity_id",
        "action": "records.action"
      },
      "resource": {
        "drniId": "records.inv_id",
        "subtype": "records.inv_subtype",
        "name": "records.inv_name",
        "resourceCharacteristic": {
          "*": {
            "name": {
              "status": {
                "$": "records.status",
                "@(2,value)": "records.matchingStatus_value"
              },
              "installDate": {
                "@(2,value)": "records.installDate"
              }
            }
          }
        }
      }
    }
}
]

If that helps please accept solution.

Thanks

avatar
Rising Star

i have slightly modifed the spec as. The matchingStatus_value doesn't provide the right result

[{
"operation": "shift",
"spec": {
"header": {
"timeStamp": "records.inv_activity_ts",
"activityId": "records.inv_activity_id",
"action": "records.action"
},
"resource": {
"drniId": "records.inv_id",
"subtype": "records.inv_subtype",
"name": "records.inv_name",
"resourceCharacteristic": {
"*": {
"name": {
"tmf639_dataSource_ingestion_uuid": {
"@(2,value)": "records.tmf639_dataSource_ingestion_uuid"
},
"createdDate": {
"@(2,value)": "records.createdDate"
},
"lastModifiedDate": {
"@(2,value)": "records.lastModifiedDate"
},
"status": {
"@(2,value)": "records.status"
}
}
}
}
}
}
}]

 

Is this a valid one?

avatar
Super Guru

if what you provided seems to be giving you the expected output then you are good to go :).