I wouldn't normally do it this way but its for a practice exercise to convert an object without using JSON.stringify(). The object to convert is below:
obj = {
num: 0,
string: "string",
func: function () {},
emptyString: '',
null: null,
undefined: undefined
};
It should produce the answer below:
'{"num":0,"string":"This is a string","emptyString":"","null":null}'
JSON.stringify
polyfills around. Just look at them to gain the insight.JSON.stringify
does a lot of things. Which in particular do you have problems with? Please ask a more specific question about what part you do not understand.