circumvent ERROR Converting circular structure to JSON when doing JSON.stringify()?

前端 未结 4 713
予麋鹿
予麋鹿 2020-12-06 02:03

For debugging I want to serialize javascript objects with JSON.stringify(myobject). But this gives:

TypeError: Converting circular structure to JSON
<         


        
4条回答
  •  悲哀的现实
    2020-12-06 02:14

    You can now use Douglas Crockford's JSON Stringify plugin:

    https://github.com/douglascrockford/JSON-js

    This has a decycle option in the download file cycle.js. You could also use console.log() and inspect the JSON in your browsers console.

提交回复
热议问题