JSON.stringify doesn't work in circulative JSON object. What to do?
-
11-02-2021 - |
Question
e.g., in Node.js, if I do this:
JSON.stringify(req);
Then I will fail because of circulative structure.
is there any setting or way to stringify it easily and skip the circulative part of structure?
Solution
Crockford's library (see cycle.js) https://github.com/douglascrockford/JSON-js supports encoding and decoding of circular objects into json (+ jsonpath).
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow