基于匹配条件的JOLT变换

问题描述 投票:0回答:1

我试图根据匹配条件使用JSONJSON转换为JOLT

如果'type':'true',请进行处理。

JSON输入:

{
     "features": [
        {
           "type": "true",
           "properties": {
           "class_lvl": "U",
           "image_url": [
              "http://www.google.com/149231_294002.jpg",
              "https://www.google.com/149231_294002.jpg"
           ],
           "review_date": "2019-03-27T15:42:02.523"              
         }
      }
    ]
  }

我想出了JOLT规格,但它没有按照我想要的方式产生:

 [
      {
          "operation": "shift",
          "spec": {
          "features": {
            "*": {
              "properties": {            
               //go up one level and check if type = true then copy image URL
                "@(1,type)": {              
                  "true": {
                    "image_url": "Parent[&3].child.grandchild"
                  }
                }
              }
            }
          }
        }
      }
   ] 
json jolt
1个回答
0
投票

此规范有效:

[
  {
    "operation": "shift",
    "spec": {
      "features": {
        "*": {
          //"type": "Parent[#].child.grandchild.type",
          "properties": {
            //go up one level and check if type = true then copy image URL
            "@(1,type)": {
              "true": {
                "@2": "Parent[#].child.grandchild"
              }
            }
          }
        }
      }
    }
  }
  ]
© www.soinside.com 2019 - 2024. All rights reserved.