1
votes

I am new to nifi. I need help to make new json template using jolttransform processor. could anyone please help to make joltspec for this requirement.

From convertavrotojson processor flow file am getting the following attributes

name, address, id,status

And from its content file, am getting mobileno.

Expecting the following output { "id": "1", "details":[ { "mobileno": "xxxxx", "name ": "AAAA", "address": "addressline1" } ], "status" :"true" }

1
Could you please share your content of the file.. - notNull
my content file {"mobileno": "111111"} - user4540719

1 Answers

1
votes

As you are having name, address, id,status attributes to the flowfile,In new versions of NiFi-1.2+ we can add attributes into json message using jolt.

Try with below jolt spec:-

[
  {
    "operation": "shift",
    "spec": {
      "mobileno": "details[0].mobileno"
    }
  },
 {
        "operation": "default",
        "spec": {
          "id":"${id}",
          "status":"${status}",
            "details[]": {
                "*": {
                  "name":"${name}",
                  "address":"${address}"
                }
            }
        }
    }
]

Jolt Config screenshot:- enter image description here

For more reference

https://community.hortonworks.com/questions/152046/nifi-how-to-use-jolt-to-add-json-keyvalue-dynamica.html