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

cu6pst1q  于 2024-01-09  发布在  其他
关注(0)|答案(1)|浏览(194)

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

  1. [
  2. {
  3. "IN_num": "3",
  4. "In_Details": "404 error",
  5. "customer_name": "vivo",
  6. "customer_location": "hyd",
  7. "customer_ID": "1003"
  8. },
  9. {
  10. "IN_num": "2",
  11. "In_Details": "404 error",
  12. "customer_name": "MI",
  13. "customer_location": "hyd",
  14. "customer_ID": "1002"
  15. },
  16. {
  17. "IN_num": "1",
  18. "In_Details": "notworking",
  19. "customer_name": "Nokia",
  20. "customer_location": "Hyd",
  21. "customer_ID": "1001"
  22. }
  23. ]

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

  1. [
  2. {
  3. "operation": "modify-overwrite-beta",
  4. "spec": {
  5. "*": {
  6. "N1": [
  7. "=isNull(@(1,customer_ID))",
  8. "NuLl"
  9. ],
  10. "N2": [
  11. "=isNull(@(1,customer_location))",
  12. "NotNuLl"
  13. ],
  14. "Condition": "=concat(@(1,N1),'_',@(1,N2))",
  15. "test": null
  16. }
  17. }
  18. },
  19. {
  20. "operation": "shift",
  21. "spec": {
  22. "*": {
  23. "IN_num": "[&1].IN_num",
  24. "In_Details": "[&1].In_Details",
  25. "customer_name": "[&1].customer_name",
  26. "test": "[&1].test",
  27. "customer_location": "[&1].customer_location",
  28. "Condition": {
  29. "NuLl_NotNuLl": {
  30. "@2,test": "customer_location"
  31. }
  32. }
  33. }
  34. }
  35. }
  36. ]


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

  1. [
  2. {
  3. "IN_num": "3",
  4. "In_Details": "404 error",
  5. "customer_name": "vivo",
  6. "test": null,
  7. "customer_location": "hyd"
  8. },
  9. {
  10. "IN_num": "2",
  11. "In_Details": "404 error",
  12. "customer_name": "MI",
  13. "test": null,
  14. "customer_location": "hyd"
  15. },
  16. {
  17. "IN_num": "1",
  18. "In_Details": "notworking",
  19. "customer_name": "Nokia",
  20. "test": null,
  21. "customer_location": "Hyd"
  22. }
  23. ]


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

91zkwejq

91zkwejq1#

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

  1. [
  2. {
  3. "operation": "modify-overwrite-beta",
  4. "spec": {
  5. "*": {
  6. "N1": ["=isNull(@(1,customer_ID))", "NuLl"],
  7. "N2": ["=isNull(@(1,customer_location))", "NotNuLl"],
  8. "Condition": "=concat(@(1,N1),'_',@(1,N2))",
  9. "test": null
  10. }
  11. }
  12. }, {
  13. "operation": "shift",
  14. "spec": {
  15. "*": {
  16. "IN_num": "[&1].IN_num",
  17. "In_Details": "[&1].In_Details",
  18. "customer_name": "[&1].customer_name",
  19. "test": "[&1].test",
  20. "Condition": {
  21. "NuLl_NotNuLl": { //if
  22. "@2,test": "[&3].customer_location"
  23. },
  24. "*": { //else
  25. "@2,customer_location": "[&3].customer_location"
  26. }
  27. }
  28. }
  29. }
  30. }]

字符串


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

展开查看全部

相关问题