I have a certain kind of requirement where instead of going from a json string and using $.parseJSON, I need to take my object and store it in a variable as string representing json.
Is there any best possible way to satisfy my requirement.
try below :
The replacer parameter can either be a function or an array of String/Numbers. It steps through each member within the JSON object to let you decide what value each member should be changed to. As a function it can return:
- A number, string, or Boolean, which replaces the property's original value with the returned one.
- An object, which is serialized then returned. Object methods or functions are not allowed, and are removed instead.
- Null, which causes the property to be removed.
As an array, the values defined inside it corresponds to the names of the properties inside the JSON object that should be retained when converted into a JSON object.
You can find theThe best way I have found is to use jQuery JSON