Support Questions
Find answers, ask questions, and share your expertise

NiFi JoltTransformJSON - Several Changes

New Contributor

Hello,

I am working with the JoltTransformJSON processor, which I consider to be very powerful but complicated to use and there is not much documentation about it.

I have the following input JSON:

 

 

{
   "logTypeCode":"FIN",
   "eventNumber":"1",
   "eventTime":1568066703172,
   "eventInfo":{
      "eventId":"CREATE_DOMESTIC_STANDING_ORDER",
      "eventVersion":"1"
   },
   "operationInfo":{
      "operationId":"DOMESTIC_STANDING_ORDER"
   }
}

 

 

 

And my output JSON I need it to be the following:

 

 

 

{
   "body":{
      "logTypeCode":"END_OF_TESTING",
      "eventNumber":"1",
      "eventTime":1568066703172,
      "eventInfo":{
         "eventId":"CREATE_DOMESTIC_STANDING_ORDER",
         "eventVersion":"1"
      },
      "operationInfo":{
         "operationId":"DOMESTIC_STANDING_ORDER"
      }
   },
   "header":{
      "date":"${dateInPropertiesFlow}"
   },
   "customValue":{
      "logTypeCode":"END_OF_TESTING",
      "ENV":"${anotherPropertie}"
   }
}

 

 

 

 

basically, I want to group everything that comes to me inside the "body" field, then I need to create another field that is called "header", which contains a single field called "date" with the value of a property that comes to me by the flow, and finally I need a field that is called "customValue", where the value "logTypeCode" has to have the same value as the field that is in "body.logTypeCode".

I'm trying several ways in the application https://jolt-demo.appspot.com/#inception but I can't get it to work as I want, for now this is the closest I got....

 

 

 

 

[
  {
    "operation": "shift",
    "spec": {
      "*": "body.&"
    }
   },
  {
    "operation": "default",
    "spec": {
      "header": {
        "date": "${paramDate}"
      }
    }
  }
]

 

I've been doing a lot of tests, but I can't get the result I need... Help!

 

Thanks

1 REPLY 1

New Contributor

can anyone help me? 

 

Thanks