how to solve (Uncaught TypeError: Converting circular structure to JSON)

bharath

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);

this gives following error

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!

Mayday

It is not possible to stringify a circular structure in JSON. Lets see a single example:

var a = { a: undefined };
var b = { b: a };
a.a = b;

Then, we have an Object:

{ a: { b: { a: { b : { a ... infinite recursion

... this results into an error you described.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Chrome sendrequest error: TypeError: Converting circular structure to JSON

TypeError: Converting circular structure to JSON in nodejs

TypeError: Converting circular structure to JSON when trying to POST request

VM1374:32 Uncaught TypeError: Converting circular structure to JSON(…)

Doing a proper MongoDB Query (TypeError: Converting circular structure to JSON)

TypeError converting circular structure to json at JSON.stringify (<anonymous>)

TypeError: Converting circular structure to JSON --> starting at object with constructor 'ClientRequest'

Angular - TypeError: Converting circular structure to JSON

Firestore references create a "TypeError: Converting circular structure to JSON"

Express Middleware: ERROR: TypeError: Converting circular structure to JSON

Elliptic : TypeError : Converting circular structure to JSON

[Vue warn]: Error in render: "TypeError: Converting circular structure to JSON

ERROR TypeError: Converting circular structure to JSON --> starting at object with constructor 'FormGroup'

TypeError: Converting circular structure to JSON property 'name' closes the circle

How do I solve "TypeError: Converting circular structure to JSON" in NodeJS

Moving code to an exported function results in TypeError: Converting circular structure to JSON

TypeError: Converting circular structure to JSON with StorybookJS on React Native

avoiding TypeError: Converting circular structure to JSON

Uncaught TypeError: Converting circular structure to JSON using JSON.stringfy inside Jquery.each

TypeError: Converting circular structure to JSON - find error in json

Amazon Cognito confirmPassword fails with (TypeError: Converting circular structure to JSON)

GraphCool TypeError: Converting circular structure to JSON

Uncaught TypeError: Converting circular structure to JSON after Angular / dependencies update

TypeError: Converting circular structure to JSON in retrieving html string from mongodb

Sequelize: TypeError: Converting circular structure to JSON

Reading fixture is throwing error TypeError: Converting circular structure to JSON

"TypeError: Converting circular structure to JSON" with GET request

"TypeError: Converting circular structure to JSON" with GET request

Axios TypeError: Converting circular structure to JSON