Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Nifi : Array of json elements to list of json elements

avatar
Explorer

I have a json input which structure is as follows:

[
  {
    "line": [
      {
        "element1": 4.908278133674332,
        "element2": 45.8293948360587
      },
      {
        "element1": 4.90838573779603,
        "element2": 45.82938855483125
      }
    ],
    "coord": 1749,
    "xenius": "LYO01749",
    "label": "R M. BASTIE",
    "date": "2018-12-17"
  },
  {
    "line": [
      {
        "element1": 7.908278133674332,
        "element2": 8.8293948360587
      },
      {
        "element1": 4.555,
        "element2": 42.34534
      }
    ],
    "coord": 223,
    "xenius": "LYO01749",
    "label": "R M. BASTIE",
    "date": "2018-12-17"
  }
]

And I would like to convert it into a list of json elements. Something like:

{
    "line": [
      {
        "element1": 4.908278133674332,
        "element2": 45.8293948360587
      },
      {
        "element1": 4.90838573779603,
        "element2": 45.82938855483125
      }
    ],
    "coord": 1749,
    "xenius": "LYO01749",
    "label": "R M. BASTIE",
    "date": "2018-12-17"
  }
{
    "line": [
      {
        "element1": 7.908278133674332,
        "element2": 8.8293948360587
      },
      {
        "element1": 4.555,
        "element2": 42.34534
      }
    ],
    "coord": 223,
    "xenius": "LYO01749",
    "label": "R M. BASTIE",
    "date": "2018-12-17"
  }

How could I do that with a json or jolt transformation, and not using SplitRecord?

Please note that I just want to get all the elements of the array and output them as a list of json elements, without the parent array.

Thanks in advance.

1 ACCEPTED SOLUTION

avatar
Master Guru
hide-solution

This problem has been solved!

Want to get a detailed solution you have to login/registered on the community

Register/Login
2 REPLIES 2

avatar
Master Guru
hide-solution

This problem has been solved!

Want to get a detailed solution you have to login/registered on the community

Register/Login

avatar
Explorer

Output Grouping... magical property 🙂

That did the trick. Thanks a lot Matt!