我hava JSON对象:
[#1={id:"2012-05-04", title:"Scheduled", start:(new Date(1336096800000)), source:{events:[#1#], className:[]}, _id:"2012-05-04", _start:(new Date(1336089600000)), end:null, _end:null, allDay:true, className:[]}]
Run Code Online (Sandbox Code Playgroud)
我尝试将其字符串化:
var test = JSON.stringify(resourceVacation, censor(resourceVacation));
function censor(censor) {
return (function() {
var i = 0;
return function(key, value) {
if (i !== 0 && typeof(censor) === 'object' && typeof(value) == 'object' && censor == value)
return '[Circular]';
++i; // so we know we aren't using the original object anymore
return value;
}
})(censor);
}
Run Code Online (Sandbox Code Playgroud)
我使用此处提到的审查:Chrome sendrequest错误:TypeError:将循环结构转换为JSON n
但是我通过浏览器获得以下异常:
未捕获的TypeError:将循环结构转换为JSON
这是Java Script对象:

我在Mozilla浏览器中使用toSource()获得了以前的JSON对象.知道怎么解决它!
============================ …
我正在使用nodejs的请求包
我在这里使用此代码
var formData = ({first_name:firstname,last_name:lastname,user_name:username, email:email,password:password});
request.post({url:'http://localhost:8081/register', JSON: formData}, function(err, connection, body) {
Run Code Online (Sandbox Code Playgroud)
和
exports.Register = function(req, res) {
res.header("Access-Control-Allow-Origin", "*");
console.log("Request data " +JSON.stringify(req));
Run Code Online (Sandbox Code Playgroud)
这里我得到这个错误TypeError:将循环结构转换为JSON
任何人都可以告诉我这是什么问题
谢谢
我使用来自http://arshaw.com/fullcalendar/的 fullcalendar jquery插件 ,我在我的网站上使用knockout js.
我添加了事件数组,日历的来源是什么.用户可以修改事件(数组).
然后我想序列化事件数组,由ajax发送,但我不能,因为日历修改我的数组,并将一个循环放入源数组.如何删除更改.为什么我的阵列中有一个循环?我读过,可能是这里有一个DOM对象.
Chrome sendrequest错误:TypeError:将循环结构转换为JSON
var a = [];
a.push({
title: "Event2",
start: "2013-09-05"
});
a.push({
title: "Event2",
start: "2013-09-15"
});
$("#calendar").fullCalendar({
events: a,
header: {
left: "title",
center: "",
right: "today prev,next"
},
editable: false
});
console.log(JSON.stringify(a));
Run Code Online (Sandbox Code Playgroud)
TypeError:将循环结构转换为JSON
我该如何解决?循环的原因是什么?
小提琴的例子,你可以看到我的问题:
在下面的代码中(在Node JS上运行)我试图打印从外部API获取的对象,JSON.stringify这会导致错误:
TypeError:将循环结构转换为JSON
我已经看过关于这个主题的问题,但没有人能提供帮助.有人可以建议:
a)我如何country从res物体中获得价值?
b)我如何打印整个物体本身?
http.get('http://ip-api.com/json', (res) => {
console.log(`Got response: ${res.statusCode}`);
console.log(res.country) // *** Results in Undefined
console.log(JSON.stringify(res)); // *** Resulting in a TypeError: Converting circular structure to JSON
res.resume();
}).on('error', (e) => {
console.log(`Got error: ${e.message}`);
});
Run Code Online (Sandbox Code Playgroud) 我正在尝试在dynamodb中的表中添加元素,如下例所示,但是当我运行它时,我收到此错误消息:Missing credentials in the config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1
aws.config.update({
region: "eu-west-1",
endpoint: "http://localhost:8080",})
let ddb = new aws.DynamoDB.DocumentClient({
apiVersion: "2012-08-10",
});
let params = {
TableName: "NameOfTheTable",
Item: {
uuid: JSON.stringify(132), // random number for testing
name: JSON.stringify(req.query.mod), //data i'm passing in
},
};
const addMod = ddb.put(params, function (err, data) {
if (err) {
console.log("Error", err);
} else {
console.log("Success", data);
}
});
return res.send(addMod);
});
Run Code Online (Sandbox Code Playgroud)
我想可能我错过了accessKeyId,accessSecretKey …
javascript database amazon-web-services node.js amazon-dynamodb