Replace null values to empty values in a JSON OBJECT

前端 未结 8 1748
無奈伤痛
無奈伤痛 2020-12-31 06:54

Hi I\'ve got a JSON object provided by an ajax request.

Some of the values inside the json appears as null, but I want an empty String inst

8条回答
  •  难免孤独
    2020-12-31 07:38

    Your function should be like this:

    function (key, value) {
        return (value == null) ? "" : value
    }
    

    Checks null and undefined values and returns an empty string

提交回复
热议问题