【问题标题】:Jolt - Transform data and filter inner array with valueJolt - 转换数据并使用值过滤内部数组
【发布时间】:2020-08-23 15:17:08
【问题描述】:

我需要解决一个困难的 Jolt。有人可以帮忙吗?

{
  "results": {
    "data": [
      {
        "name": "xx",           
        "typeRelationship": [
          {
            "relationship": "parent",
            "type": {                
              "id": "yyyyy",                 
            }
          }
        ],
        "id": "xxxxxxxx"
      },
      {
        "name": "yy",         
        "typeRelationship": [
          {
            "relationshipType": "parent",
            "type": {
              "id": "CCCC"
            }
          },
          {
            "relationshipType": "child",
            "service": {
              "id": "DDDD"
            }
          },
          {
            "relationshipType": "child",
            "service": {
              "id": "xxxxxxxx"
            }
          }
        ],
        "id": "yyyyy"
      }
    ]
  }
}

所有我需要发生的事情,一个 JOLT 来根据这个条件进行过滤: results.data.typeRelationship.type.id = xxxxxxxx

所以结果应该过滤并显示:

{
  "rows" : [  {
    "rowdata" : {
      "relationshipType" : "child",
      "Name" : "yy",
      "id" : "yyyyy"
    }
  } ]
}

【问题讨论】:

    标签: jolt


    【解决方案1】:

    这行得通,

    [
      {
        "operation": "shift",
        "spec": {
          "results": {
            "data": {
              "*": {
                "typeRelationship": {
                  "*": {
                    "type|service": {
                      "id": {
                        "xxxxxxxx": {
                          "@(3,relationshipType)": "rows[&6].rowdata.relationshipType",
                          "@(5,name)": "rows[&6].rowdata.Name",
                          "@(5,id)": "rows[&6].rowdata.id"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    ]
    

    【讨论】:

    • 谢谢,看来它可以工作了,我的数组中只有一个空记录,我需要摆脱 THanks,
    猜你喜欢
    • 1970-01-01
    • 2022-06-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-11
    • 2021-10-29
    相关资源
    最近更新 更多