javascript - How can I print a circular structure in a JSON-like format?

Published: 12 April 2024
on channel: Code Samples
230
1

I have a big object I want to convert to JSON and send. However it has circular structure, so if I try to use JSON.stringify() I'll get:

TypeError: Converting circular structure to JSON

or

TypeError: cyclic object value

I want to toss whatever circular references exist and send whatever can be stringified. How do I do that?
Thanks.
var obj = {
a: "foo",
b: obj
}

I want to stringify obj into:
{"a":"foo"}


Watch video javascript - How can I print a circular structure in a JSON-like format? online without registration, duration hours minute second in high quality. This video was added by user Code Samples 12 April 2024, don't forget to share it with your friends and acquaintances, it has been viewed on our site 230 once and liked it 1 people.