0
votes
{"books": {
"Harry Potter": {
   "text": "There are several harry potter books:/n-Chamber of Secrets/n--chess/n--dog/n-Goblet of Fire/n--dragon/n--broomstick "
}

}

The above JSON object. I would like to convert the text field to the following

There are several harry potter books:
-Chamber of Secrets
  --chess
  --dog
-Goblet of Fire
  --dragon
  --broomstick

You can see that there is a title, Two topics, and two subtopics I would like to separate each into the following type of JSON object

{"books": {
"Harry Potter": {
   "subject": "There are several harry potter books:",
       "book 1" : { 
        "title": "-Chamber of Secrets",
        "Contents 1" : "--chess",
        "Contents 2" : "--dog"},
           "book 2" : { 
             "title":"-Goblet of Fire",
            "Contents 1" : "--dragon",
            "Contents 2" : "--broomstick"}
}
}}

Ideally I would like to be able to do this dynamically. different amount of books and contents within books. I am using NiFi JOLT Transform any help with the specification would be greatly appreciated

1

1 Answers

1
votes

I'm not sure JOLT has the function(s) to be able to do this dynamically, for NiFi you're probably looking at a scripted solution (ExecuteScript with Groovy for example).