Nifi JOLT 将字符串分隔为不同的元素和子元素 [英] Nifi JOLT Transform string delimited into different elements and subelements

查看:34
本文介绍了Nifi JOLT 将字符串分隔为不同的元素和子元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

{"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 "
}

}

上面的JSON对象.我想将文本字段转换为以下内容

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

可以看到有一个标题,两个主题,两个副主题我想将每个分成以下类型的 JSON 对象

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"}
}
}}

理想情况下,我希望能够动态执行此操作.不同数量的书籍和书籍中的内容.我正在使用 NiFi JOLT Transform 对规范的任何帮助将不胜感激

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

推荐答案

我不确定 JOLT 是否具有能够动态执行此操作的功能,对于 NiFi,您可能正在查看脚本化解决方案 (ExecuteScript以 Groovy 为例).

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).

这篇关于Nifi JOLT 将字符串分隔为不同的元素和子元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆