3

I have a JSON object of format:

obj { 
 name: "abc" , 
 entriesList : "list of entry obj" , 
 propertiesList : "list of properties obj" 
};

where entry is also another object

entry { 
 info : "data obj" , 
 age : "15" , 
 subjects : "5"
}
properties { 
 a : "a" , 
 b : "b" 
}
data { 
 c : "c" , 
 d : "d"
}

Using JSON.stringify() it is giving error

cyclic object value

How should I convert my object to JSON string?

Mariusz Jamro
31.9k25 gold badges129 silver badges170 bronze badges
asked May 26, 2015 at 3:43
6
  • 1
    Isn't JSON.parse reverse of JSON.stringify i.e. converting JSON string to JSON obj? whereas my need is stringily Commented May 26, 2015 at 3:47
  • Is your JSON cyclic? Is the original 'obj' an entry object? Commented May 26, 2015 at 3:52
  • @crc442 No, it does't looks cyclic to me. Original obj is not an entry object. Commented May 26, 2015 at 3:53
  • Can you post the actual data? Commented May 26, 2015 at 3:55
  • I can't post actual data but I am trying to come up with more clear analogy. Commented May 26, 2015 at 4:13

1 Answer 1

1

I can't see a cycle from your example, but the idea is to not include cyclic references in your object. I mean to avoid something like this:

var a = {}, b = {};
a.child = b;
b.child = a; //This will cause a cyclic reference when calling JSON.stringify both on a and b object
answered May 26, 2015 at 3:50
Sign up to request clarification or add additional context in comments.

1 Comment

I understood not to include cycles references and I can't see cyclic references as well.But I am getting error as cyclic object value.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.