Say for example if I have a 3 level deep javascript object
{CONN_INFO: {CFGSwitch: {412: {}}}}
How can I write a function that determines if it is nested?
And secondly, how can I then convert the empty object {} to a string such as "{}"
How can I write a function that determines if it is nested?
For all keys of the current object, check its type, if JSON then nesting is present.
And secondly, how can I then convert the empty object {} to a string such as "{}"?
If you encounter a nested JSON object, check for its key length using Object.keys(currentJSONObj).length, if 0 then this is an empty JSON. So re-assign "{}" to the key which had empty JSON object at first place.
{}is not anullvalue. It is an empty object. If youalert({}==null)you will getfalse.