Kettle数据分析

kettle json处理

2019-07-04  本文已影响1人  默直

Kettl处理JSON文件


Kettle处理JSON文件的文件格式,必须包含“[]”,否则不会成功;

第一种格式(包含[]):
{ "book": [{ "category": "reference", "author": "Nigel Rees","title": "Sayings of the Century", "price": 8.95},

          {"category":"reference","author":"Nigel Rees", "title":"Sayings of the Century","price":8.95}

        ],

"bicycle":{"color": "red", "price": 19.95}

}

JSON格式

第二种格式:

[{ "category": "reference", "author": "Nigel Rees","title": "Sayings of the Century", "price": 8.95},

          {"category":"reference","author":"Nigel Rees", "title":"Sayings of the Century","price":8.95}

]

JSON格式

示例:

示例

第一步:打开kettle软件,选择“自定义常量数据”,如图json格式数据。不难发现,每条数据都有“[]”.

注:由于kettle软件关系,没有[],会报错。

json数据

第二步:选择“Json输入”组件,打开此组件,【文件】选择“源定义在一个字段里”打钩,“用字段获得源”获得需要处理的字段。

Json设置

第三步:选择【内容】,如图设置。

内容设置

第四步:选择【字段】,“名称”是JSON中字段名称,“路径”,是“名称”的路径,一般路径是:$..+json中字段名称,“类型”设置数据类型。

字段设置

第五步:执行--》结果

结果

注:如果json报文实第二种格式,不要害怕数据缺失,【json输入】组件会自动生成两列,防止数据丢失。


谢谢浏览,点个赞再走呗。

上一篇 下一篇

猜你喜欢

热点阅读