如何解决(未捕获的TypeError:将圆形结构转换为JSON) [英] how to solve (Uncaught TypeError: Converting circular structure to JSON)
本文介绍了如何解决(未捕获的TypeError:将圆形结构转换为JSON)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下对象,我正尝试将其转换为json对象,如下所示:
i have the following object and i am trying to convert it to json object as follows
var feeTransactionsArray=[];
$(".editor #newPayTable .mainTr").each(function(){
var feeTransactions={};
var studentDetails={};
var feeCategory={};
studentDetails['studentAdmissionId']=id;
feeCategory['feeCatId']=$(this).find('.feeCatId').val();
feeTransactions['studentDetails']=studentDetails;
feeTransactions['feeCategory']=feeCategory;
feeTransactions['paidOn']=paidDate;
feeTransactions['transReceiptNo']=receciptNumber;
feeTransactions['amountPaid']=$(this).find('.amount').val();
feeTransactions['paymentMode']=mode
feeTransactions['amountPaid']=refrenceNumber;
feeTransactions['isConcessionGiven']='no';
feeTransactionsArray.push(feeTransactionsArray);
});
var myJSON = JSON.stringify(feeTransactionsArray);
这给出了以下错误
actions.js:1180 Uncaught TypeError: Converting circular structure to JSON
at JSON.stringify (<anonymous>)
如何解决我的情况.请帮我.谢谢!
how to solve this in my case. please help me. thank you!
推荐答案
无法在JSON中对循环结构进行字符串化.让我们看一个例子:
It is not possible to stringify a circual structure in JSON. Lets see a single example:
var a = { a: undefined };
var b = { b: a };
a.a = b;
然后,我们有了对象:
{ a: { b: { a: { b : { a ... infinite recursion
会导致您描述的错误.
这篇关于如何解决(未捕获的TypeError:将圆形结构转换为JSON)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文