2

I'm working on a small project and I wanted to export an array of JSON objects into a text file. I came across this handy console.save() function for Chrome Dev Tools, and decided to use it. My library, leapcapjs has an exposed function that is the following:

LeapCap.getSavedFrames = function(){
    return SAVED_FRAMES;
} 

where SAVED_FRAMES is a global variable. In order to export this array to a string, I typed the following into my dev console:

console.save(LeapCap.getSavedFrames());

As a result, I get the following error:

TypeError: Converting circular structure to JSON 

Anyone know what the problem could be? Thanks!

EDIT: SAVED_FRAMES is populated with frameData objects:

SAVED_FRAMES.push(frameData);

A frameData object is made like this:

LEAP_CONTROLLER.on('frame', function (frame) {
        if (!PAUSE_LEAP) {
            var frameData = {
                'interaction_box': frame.interactionBox,
                'hands': frame.hands
            };
            drawWith(frameData);
        }
    });

Could some of the LeapJS API objects be causing the problem? If so, how can I stop this?

6
  • Does the contents of SAVED_FRAMES point to itself anywhere? Commented Mar 6, 2014 at 1:13
  • some property in the returned object from getSavedFrames has a circular reference, ie a child property refers to a parent object Commented Mar 6, 2014 at 1:13
  • As an aside, get used to this error; you'll see it a LOT when trying to display JSON objects in Javascript. Commented Mar 6, 2014 at 1:14
  • @alex, nope it does not. Commented Mar 6, 2014 at 1:21
  • @PatrickEvans, I've updated the original post with how SAVED_FRAMES is populated. Maybe that might help. Commented Mar 6, 2014 at 1:21

0

Your Answer

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.