[TypeError: JSON.stringify cannot serialize cyclic structures.] object
See original GitHub issueI’m getting error [TypeError: JSON.stringify cannot serialize cyclic structures.] object
when i try to convert realm object to json object using
JSON.parse(JSON.stringify(item))
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Serializing object that contains cyclic object value
Use the second parameter of stringify , the replacer function, to exclude already serialized objects: var seen = []; JSON.stringify(obj, ...
Read more >TypeError: cyclic object value - JavaScript - MDN Web Docs
The JavaScript exception "cyclic object value" occurs when object ... TypeError: JSON.stringify cannot serialize cyclic structures. (Safari) ...
Read more >Random error 'JSON.stringify cannot serialize cyclic structures'
The error was on trying to call the API (Executing the API post method) it failures random on different days only with mobile...
Read more >React Native JSON.stringify cannot serialize cyclical structures
iOS : React Native JSON. stringify cannot serialize cyclical structures [ Beautify Your Computer : https://www.hows.tech/p/recommended.html ] ...
Read more >iOs9 XCODE error: JSON.stringify cannot serialize cyclic ...
error JSON.stringify()ing argument: TypeError: JSON.stringify cannot serialize cyclic structures. I do not know what is causing this error ...
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 Free
Top 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
Yes
toJSON()
returns the same structure, where instances ofRealm.Object
&Realm.Collection
has been replaced by flat JS objects & arrays. For more info ontoJSON
, see MDN toJSON.Realm.JsonSerializationReplacer
is intended as a replacer (2nd argument) forJSON.stringify
, is this how you utilized it? (see example bellow).If downgrading to realm@6.0.3 fixed the circular structure error, could I ask you to supply some code or a small project (node/RN version used), where the error occurs in 6.1.0 and not in 6.0.3?
@mahipalsingh-syt
Realm.JsonSerializationReplacer
is only intended for serialization to a string, where serialization is not possible due to circular references (e.g. a JSON export) - the added$ref
is to indicate, in a readable manner, to where the circular reference points. In other words: parsing it would require additional logic.If you’re “just” trying to make a copy of the
Realm.Object
as plain JS (your naming highly indicates this), then please try this instead (only works on 6.1.0+):This should keep the circular references through the objects.
Let me know if it yields problems.