A
A
askold20132018-03-19 16:37:43
JavaScript
askold2013, 2018-03-19 16:37:43

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

1 answer(s)
E
ElijahTr, 2018-03-19
@ElijahTr

https://codepen.io/elijah_tr/pen/RMKryo
Will it work?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question