Let's say I have this js object:
{"a": null, "b": 5, "c": 0, d: "", e: [1,2,null, 3]}
This is what I would like to get:
{"a": "null", "b": 5, "c": 0, d: "", e: [1,2,"null", 3]}
The only idea I have is to use:
function nullToString(v) {
return JSON.parse(JSON.stringify(v).split(":null").join(":\"null\""));
}
But it seems like a quite expensive operation comparing with what I would like to achieve.
If there is any helpful method from jQuery or underscore.js that would be great.