Converting circular structure to JSON (Drupal entity reference field)
See original GitHub issueHi, 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:
- https://www.npmjs.com/package/safe-json-stringify
- https://www.npmjs.com/package/json-stringify-safe
- https://www.npmjs.com/package/fast-safe-stringify
- https://www.npmjs.com/package/fast-json-stable-stringify
but in this case, how could I override the functions?
Related issues:
- https://github.com/vercel/next.js/discussions/10992
- https://www.drupal.org/project/drupal/issues/3039730
Thanks.
Issue Analytics
- State:
- Created a year ago
- Comments:7 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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!
I tried that but I get Nodes for multiple Node bundles from views 😃. Which probably does not work even if I use: