Answer the question
In order to leave comments, you need to log in
How to convert an object containing functions to JSON and back?
Hello! There is an object in which there are fields containing various data, including nested ones, and containing functions.
JSON.stringify() cannot convert a function to a string.
Question - how can I convert the entire object to JSON, and then parse it back to the original object?
The .toSource() method can do this, but how do you return it back to the original function? eval()? Not suitable - because it is inconvenient - you need to completely restore the original object from the string.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question