Forum Discussion

Manzoor's avatar
Manzoor
New Contributor
2 years ago
Solved

How to replace the fields having "NULL" and write as Blank I.E " "

Hi team,

 

There are few fields where I'm having value as NULL, I want to make NULL in to blank,  in all the Fields where I have the NULL. Help me in a way so that I can write a logic which can replace all the NULL in to Blank.

Thanks in Advance.

  • Hi Manzoor ,

    Depending on your input data, if you have a flat object, you can make all of the NULL fields blank by using the following expression:

    $.mapValues(val => val == null ? "" : val)

    This will iterate over each value for each key in the input data and depending if the value is null, it will return an empty string otherwise it will return the original value.

     

    Input data sample:

    [
        {
            "msg": "Hello, World",
            "num": 1,
            "field2": null
        }
    ]

     

    Output:

    [
      {
        "msg": "Hello, World",
        "num": 1,
        "field2": ""
      }
    ]

2 Replies

  • Hello yes1819,

    Make sure to remove the single quotes from '$VERSION', so you can get the value of the $VERSION field from upstream.

    Try this and let me know if this helps you.

    Regards,

    Aleksandar.

    • yes1819's avatar
      yes1819
      New Contributor III

      Thank you

      I removed the single quotes but it says this

       

       

       

      • Aleksandar_A's avatar
        Aleksandar_A
        Contributor III

        Probably you are not passing the $VERSION field from upstream, if you can provide us with more details about your flow, than we can better understand what you are trying to achieve here.