skip to Main Content

Below is my JSON and i need JOLT to remove if destSiteName is unknown. Need to keep the rest of the object.

{
  "destSiteName": "unknown",
  "customer_code": "code1"
}

2

Answers


  1. {
      "operation": "shift",
      "spec": {
        "destSiteName": {
          "unknown": null,
          "*": "&"
        },
        "*": "&"
        }
      },
      {
        "operation": "remove",
        "spec": {
          "destSiteName": ""
       }
     }
    
    Login or Signup to reply.
  2. You might use a shift transformation which contains two conditionals

    • whether outermost attribute is "destSiteName" or not ( "*" )

    or

    • whether value of "destSiteName" is "unknown" or not ( "*" )
    [
      {
        "operation": "shift",
        "spec": {
          "destSiteName": {
            "unknown": "",
            "*": { "@1": "&2" }
          },
          "*": "&"
        }
      }
    ]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search