我正试图严格化(…)Chrome中的一个对象,我一直收到一条"将循环 struct 转换为JSON"的消息,尽管事实上(据我所知)不存在这样的 struct .

I've been over the code a dozen times and can't find any circular references whatsoever. Is there any way to get Chrome to tell me what it's bitching about beyond this painfully useless error message?

推荐答案

如果这太明显,请原谅.在写这篇文章的时候,我不知道你试过什么.

插入

console.log(the object); 

replacing 'the object' with the object you are passing to JSON.stringify()

插入 this line before the JSON.stringify call

and look in the console log (shift control J) for the object. In the console log the object will be tagged with a ">" symbol which can be clicked to expand to the fields.

It is complaining about an object that has pointers into itself, like this kind of object:

A = [];
A[0] = A; 
JSON.stringify(A); // circular error

Json相关问答推荐

手动解开没有可编码的SON- Swift

与错误相关的未定义&Quot;不是有效的JSON

无法使用Jolt变换在嵌套的JSON中提取值

错误:在 NX 工作区中找不到模块../swagger.json

爆炸没有数组的 struct pyspark

在 PowerShell 中通过 aws cli 创建 cloudwatch alert 时出现字符串解析错误

Python 将 struct 化文本转换和筛选为对象

如何在 Flutter 中遍历嵌套的动态 JSON 文件

在Flutter 中将 map 的 Json 转换为 list

如何为包含一些固定值并可能具有其他附加值的数组字符串创建数组 json 架构

SwiftUI:如何使用 0 索引数组键为 JSON 添加类型

使用基本身份验证通过 CURL 发布 JSON

一起使用 Argparse 和 Json

Spring MVC 4:application/json内容类型设置不正确

反序列化大型 json 对象的 JsonMaxLength 异常

什么是类型和类型令牌?

TypeError: b'1' 不是 JSON 可序列化的

在android中读取Json数组

Volley JsonObjectRequest Post 参数不再起作用

为什么 RestTemplate 不将响应表示绑定到 PagedResources?