json 我如何给一个已经有值的键分配空值,我需要给一个键分配空值,因为它满足一个条件

cu6pst1q  于 5个月前  发布在  其他
关注(0)|答案(1)|浏览(83)

基于一个条件,即如果两个表中的客户名称匹配,则其中一个表中的少数列应分配为**null。我有所有匹配条件的输入,但我无法将所需列设置为null**
输入:

[
  {
    "IN_num": "3",
    "In_Details": "404 error",
    "customer_name": "vivo",
    "customer_location": "hyd",
    "customer_ID": "1003"
  },
  {
    "IN_num": "2",
    "In_Details": "404 error",
    "customer_name": "MI",
    "customer_location": "hyd",
    "customer_ID": "1002"
  },
  {
    "IN_num": "1",
    "In_Details": "notworking",
    "customer_name": "Nokia",
    "customer_location": "Hyd",
    "customer_ID": "1001"
  }
]

字符串
我已经尝试创建一个假的null值,并将其分配给所需的键,但我仍然得到了键已经存在的值。
我的规格:

[
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "*": {
        "N1": [
          "=isNull(@(1,customer_ID))",
          "NuLl"
        ],
        "N2": [
          "=isNull(@(1,customer_location))",
          "NotNuLl"
        ],
        "Condition": "=concat(@(1,N1),'_',@(1,N2))",
        "test": null
      }
    }
  },
  {
    "operation": "shift",
    "spec": {
      "*": {
        "IN_num": "[&1].IN_num",
        "In_Details": "[&1].In_Details",
        "customer_name": "[&1].customer_name",
        "test": "[&1].test",
        "customer_location": "[&1].customer_location",
        "Condition": {
          "NuLl_NotNuLl": {
            "@2,test": "customer_location"
          }
        }
      }
    }
  }
]


在这里,customer location有一个现有值,但我希望将其打印为“"。
我得到的输出:

[
  {
    "IN_num": "3",
    "In_Details": "404 error",
    "customer_name": "vivo",
    "test": null,
    "customer_location": "hyd"
  },
  {
    "IN_num": "2",
    "In_Details": "404 error",
    "customer_name": "MI",
    "test": null,
    "customer_location": "hyd"
  },
  {
    "IN_num": "1",
    "In_Details": "notworking",
    "customer_name": "Nokia",
    "test": null,
    "customer_location": "Hyd"
  }
]


对于关键字““customer_location”,我希望值为“”或null。
如何进行这件事?

91zkwejq

91zkwejq1#

我不确定你的预期结果。如果你正在寻找一个条件,如if else语句,那么下面的规范可以帮助你。

[
{
"operation": "modify-overwrite-beta",
"spec": {
  "*": {
    "N1": ["=isNull(@(1,customer_ID))", "NuLl"],
    "N2": ["=isNull(@(1,customer_location))", "NotNuLl"],
    "Condition": "=concat(@(1,N1),'_',@(1,N2))",
    "test": null
  }
}
}, {
"operation": "shift",
"spec": {
  "*": {
    "IN_num": "[&1].IN_num",
    "In_Details": "[&1].In_Details",
    "customer_name": "[&1].customer_name",
    "test": "[&1].test",
    "Condition": {
      "NuLl_NotNuLl": { //if
        "@2,test": "[&3].customer_location"
      },
      "*": { //else
        "@2,customer_location": "[&3].customer_location"
      }
    }
  }
}
}]

字符串


的数据
让我们知道如果你正在寻找不同的东西。

相关问题