PDI(Kettle)的使用三 获取REST api数据并保存为文件
获取REST api数据并保存到json文件里
1.新建转换
2.设置
(1)核心对象,拖拽
生成记录,REST client,Json input,Json output
并依次连接(按shift+鼠标拖拽)
(2)编辑生成记录
(3)编辑REST client
(4)编辑Json input
设置获取的字段
说明:
根据返回的数据格式设置
{ "code": 200, "message": "SUCCESS", "data": { "total": 3, "list": [ { "id": 13, "fileName": "aa.txt", "size": 9084, "status": 5, "uploadTime": "2020-12-18 11:26:08", }, { "id": 12, "fileName": "bb.pdf", "size": 1729, "status": 5, "uploadTime": "2020-12-18 11:25:03", }, { "id": 11, "fileName": "cc.ppt", "size": 9451, "status": 5, "uploadTime": "2020-12-18 11:20:11", } ] } }
(4)编辑Json output
输出字段
3.保存并执行
保存到json的数据为
{ "lists": [ { "fileName": "aa.txt", "fileSize": "9084", "id": "13" }, { "fileName": "bb.pdf", "fileSize": "1729", "id": "12" }, { "fileName": "cc.ppt", "fileSize": "9451", "id": "11" } ] }
附加:
不在url中指定参数size,使用post的formdata传递size
设置传递参数size