zoukankan      html  css  js  c++  java
  • 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

     

     

  • 相关阅读:
    C#4.0和VS2010新特性
    对于大型公司项目平台选择j2ee的几层认识
    移动开发
    第四讲 GridView 72般绝技
    String字符串补0或空格
    org.apache.commons.io使用实例
    BigDecimal
    JAVA String.format 方法使用介绍
    SimpleDateFormat使用详解
    java四舍五入
  • 原文地址:https://www.cnblogs.com/baby123/p/14207549.html
Copyright © 2011-2022 走看看