0

Here is my input :

   { "isPoolPoint": "test", "timeZone": "ET" }

I want output to be :

   { "address" : [{"line2": "test"}] }

I should not get any thing as output if isPoolPoint is a null.

Zac
  • 1,305
  • 3
  • 17
  • 28
  • Hello! Welcome to *StackOverflow*. Please go through [how to ask](https://stackoverflow.com/help/how-to-ask) before asking a question. Also, please provide a [minimal example](https://stackoverflow.com/help/mcve) of the code that you have tried so far. Show some effort that you have put and I'm sure we'll be able to help you from there on. – Zac Jul 31 '18 at 09:53

2 Answers2

2

Spec

[
  {
    "operation": "shift",
    "spec": {
      "isPoolPoint": {
        // match down into the values of "isPoolPoint"
        // if we match null, then do nothing
        "null": null,
        // match everything else
        "*": {
          // write what was matched to the output
          "$": "address[0].line2"
        }
      }
    }
  }
]
Barbaros Özhan
  • 59,113
  • 10
  • 31
  • 55
Milo S
  • 4,466
  • 1
  • 19
  • 22
0
I wanted to ignore blank strings as well in addition to null values so I did below extra condition

[
  {
    "operation": "shift",
    "spec": {
      "isPoolPoint": {
         // OR operator below will care of empty string or null
        "|null": null,
        "*": {
          "$": "address[0].line2"
        }
      }
    }
  }
]
sapan prajapati
  • 1,514
  • 19
  • 16