Hey folks,

I am having a hard time figuring out how to work with date values in json
documents using the standard processors available in Nifi.

example flowfile:

{
   "time": "2017-01-01T01:14:55+00:00",
   "any": {
      "nested": "data"
    }
}

what i want:

{
  "time": 1483233295,
   "any": {
      "nested": "data"
    }
}

I can extract the time field into an attribute with EvaluateJsonPath and
then  using nifi expression language I can get a timestamp in seconds:

${time:toDate("yyyy-MM-dd'T'hh:mm:ss'+00:00'"):toNumber():divide(1000)}

I can't find a way to get that value back into my document without losing
nested data structures (AttributesToJson).

I can't find anything in jolt-core that enables working with dates.

Has anyone else been able to solve a transformation like this or know of a
way to do it with standard nifi processors?

If not? What options for enhancement seem best?

- Enhance EvaluateJsonPath to be able to write to individual properties in
a json document. Currently it can only overwrite the flowfile with the
value of a single jsonpath expression.

example properties:
$.time :
${time:toDate("yyyy-MM-dd'T'hh:mm:ss'+00:00'"):toNumber():divide(1000)}

- Extend Jolt with a customer transformer class

- Enhance AttributesToJson to allow writing nested data structures. Behind
a flag, each attribute value would be tested to see if it is valid json.

Thanks,
Nick

Reply via email to