0
votes

I'm using Apache NiFi and I get some JSON as input. I want to create a new JSON, as follows:

{
     "data": ORIGINAL_JSON_HERE,
     "new_field_1": "field_1_value",
     "new_field_2": "field_2_value"
}

Where field1,field2 does not depend on the JSON, thus the values are not relevant.

In the following demo-site (made by the original creator of the Java Jolt library):

http://jolt-demo.appspot.com/#inception

If I do the following spec:

[
  {
    "operation": "shift",
    "spec": {
      "*": "&"
    }
  }
]

However, when I use the same spec in NiFi JOLT processors, I get null as output...

How can I find the correct spec for NiFi?

1

1 Answers

2
votes

The problem was that I wanted the output JSON to have a data field, but I didn't specifiy an operation to create such field. The following works:

[
  {
    "operation": "shift",
    "spec": {
        "*": "data.&"
    }
  },
  {
    "operation": "default",
    "spec": {
        "data": {},
    }
  }
]