小编Stu*_*Kon的帖子

How to convert All json values to String without iteration

I have JSON in which all the values have to be changed to string. The values may be a number, boolean, undefined or null.

{
    "obj1": [{
        "n1": "n",
        "n2": 1,
        "n3": true
    },
    {
        "n1": "n",
        "n2": 1,
        "n3": null
    }]
}
Run Code Online (Sandbox Code Playgroud)

The expected result is all the values should be formatted as a string.

Example:

{
    "obj1": [{
        "n1": "n",
        "n2": "1",
        "n3": "true"
    },
    {
        "n1": "n",
        "n2": "1",
        "n3": "null"
    }]
}
Run Code Online (Sandbox Code Playgroud)

By iterating through …

javascript json

2
推荐指数
1
解决办法
255
查看次数

标签 统计

javascript ×1

json ×1