【问题标题】:How to write the esql code for a json response from the json request as input?如何为来自 json 请求的 json 响应编写 esql 代码作为输入?
【发布时间】:2022-01-21 19:45:28
【问题描述】:

请求->

{
    "data": 
      {
      "type": "employee",
      "attributes": 
           [
            {
             "name": "Sam",
             "empId": 1,
             "grade": "A"
            },
            {
             "name": "Barsa",
             "empId": 2,
             "grade": "A"
            },
             "name": "Ram",
             "empId": 3,
             "grade": "B"
            }
           ]
       }
}

响应->##


 ##
{
    "data": 
      {
      "type": "grade",
      "employees": 
           [
            {
             "name": "Sam",
             "empId": 1,
             "grade": "A"
            },
            {
             "name": "Barsa",
             "empId": 2,
             "grade": "A"
            },
             "name": "Ram",
             "empId": 3,
             "grade": "B"
            }
           ]
       }
}

【问题讨论】:

    标签: arrays json ibm-integration-bus


    【解决方案1】:

    Modifying a JSON messageSET statement 章节解释了如何执行以下操作:

    CREATE FUNCTION Main() RETURNS BOOLEAN
    BEGIN
        SET OutputRoot = InputRoot;
        SET OutputRoot.JSON.Data.data.type = 'grade';
        SET OutputRoot.JSON.Data.data.attributes NAME = 'employees';
        RETURN TRUE;
    END;
    

    注意:您的请求消息是无效的 json:"name": "Ram", 之前的 { 丢失。

    【讨论】:

      猜你喜欢
      • 2019-07-07
      • 1970-01-01
      • 1970-01-01
      • 2017-10-08
      • 2016-04-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多