question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Converting circular structure to JSON (Drupal entity reference field)

See original GitHub issue

Hi, has anyone solved the issue “Converting circular structure to JSON” where JSON:API loops over an entity reference in Drupal. I get this when a Node references other Nodes which they reference back to the Node on a JSONAPI get call.

I can see that the next-drupal functions are using the native JSON.stringify(). Some people propose to use a more safe npm like:

but in this case, how could I override the functions?

Related issues:

Thanks.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
theodorosploumiscommented, May 27, 2022

My fault, it works! I can use multiple fields. You saved me many hours! I would spend a lot of time with this…

Thank you both!

0reactions
theodorosploumiscommented, May 27, 2022

I tried that but I get Nodes for multiple Node bundles from views 😃. Which probably does not work even if I use:

"fields[node--article]": "title,path,field_name",
"fields[node--blog]": "title,path,field_name", 
Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Converting circular structure to JSON - Drupal
This error usually shows up when an object has a property that references itself, and the result is being converted to JSON. For...
Read more >
What is TypeError: Converting circular structure to JSON?
TypeError: Converting circular structure to JSON occurs when you try to reference your variable name within the JSON object.
Read more >
TypeError: Converting circular structure to JSON in JS
The "Converting circular structure to JSON" error occurs when we pass an object that contains circular references to the JSON.stringify() method.
Read more >
TypeError: Converting circular structure to JSON - Stack ...
It means that the object you pass in the request (I guess it is pagedoc ) has a circular reference, something like: var...
Read more >
Converting circular structure to JSON at JSON.stringify ...
@tonysneed , if I use same code without trackable entity at JS client side, it works fine. it is throwing circular reference issue...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found