0
votes

I am applying Jolt to NiFi but I am not getting the expected result.

Result

{
   "from": "2020-07-16T18:14:00+00:00",
   "to": "2020-07-16T18:15:00+00:00",
   "values":
   {
       "score": 1.0,
       "s": 0,
       "t": 0,
       "f": 0,
       "count": 0,
       "value": null,
       "threshold": 0.5,
       "threshold_min": 0.5
   },
   "aplication": "Magento",
   "name": "ApdexAll"
}

Jolt

  [{
        "operation": "shift",
        "spec": {
            "*": "&"
        }
    }, {
        "operation": "default",
        "spec": {
            "aplication": "${aplication}",
            "name": "${name}"
        }
    }]

I need a json with just one level

{
    "aplication": "Magento",
    "name": "ApdexAll",
    "from": "2020-07-16T18:14:00+00:00",
    "to": "2020-07-16T18:15:00+00:00",
    "values":
    {
        "score": 1.0,
        "s": 0,
        "t": 0,
        "f": 0,
        "count": 0,
        "value": null,
        "threshold": 0.5,
        "threshold_min": 0.5
    }
}
1
Both your input and output looks similar. - Jagadesh

1 Answers

0
votes

By "just one level" you mean adding the attributes from values to the root of your json?

If thats the case the spec would be:

[{
  "operation": "shift",
  "spec": {
    "*": "&",
    "values": {
      "*": "&"
    }
  }
    }, {
  "operation": "default",
  "spec": {
    "aplication": "${aplication}",
    "name": "${name}"
  }
    }]

And you would get this as output:

{
  "from" : "2020-07-16T18:14:00+00:00",
  "to" : "2020-07-16T18:15:00+00:00",
  "score" : 1,
  "s" : 0,
  "t" : 0,
  "f" : 0,
  "count" : 0,
  "value" : null,
  "threshold" : 0.5,
  "threshold_min" : 0.5,
  "aplication" : "magento",
  "name" : "ApdexAll"
}