kettle输入组件-JSON Input的使用案例

来源:互联网 发布:java递归求和 编辑:程序博客网 时间:2024/05/16 04:38

用例背景说明

数据文件car_factory.js,其内容如下:

{
"RECORDS":[
{
"factory_id":"10",
"factory_name":"一汽奔腾",
"name_index":"Y",
"picture_path":null
},
{
"factory_id":"107",
"factory_name":"劳斯莱斯",
"name_index":"L",
"picture_path":null
},
{
"factory_id":"108",
"factory_name":"阿斯顿马丁",
"name_index":"A",
"picture_path":null
},
{
"factory_id":"11",
"factory_name":"一汽马自达",
"name_index":"Y",
"picture_path":null
}
]
}

现在要将car_factory.js文件加载到mysql数据库中,数据库对应表DDL:

DROP TABLE IF EXISTS car_factory;
CREATE TABLE car_factory (
  factory_id varchar(45) NOT NULL,
  factory_name varchar(100) DEFAULT NULL,
  name_index varchar(1) DEFAULT NULL,
  picture_path varchar(200) DEFAULT NULL,
  PRIMARY KEY (factory_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


1.整体设计


2.JSON Input Step设置

设置json文件


设置字段映射,注意path的填写方式要遵照jsonpath规则,每一级子对象可以用一个.指代,有关jsonpath的说明,参考http://goessner.net/articles/JsonPath/




数据预览


关于kettle组件说明部分参考网址:http://wiki.pentaho.com/display/EAI/Pentaho+Data+Integration+Steps


kettle官方给出的参考用例:

data-integration\samples\transformations\JsonInput - read a dynamic file.ktr
data-integration\samples\transformations\JsonInput - read a file.ktr
data-integration\samples\transformations\JsonInput - read incoming stream.ktr


0 0
原创粉丝点击