JSON.parse error, won't parse something I just JSON.stringify'd

So I have this really large object that I use to control things in a nodejs app. Occasionally I store this object in a database [mysql] so if the process crashes or gets restarted and something's been changed, the changes will be saved. Pretty simple.

The object is this: http://snippi.com/s/z5nq0v5

it's defined as global.config.

So to store, I use my save function:

    client.query('SELECT data FROM settings WHERE (id = \''+ config.room +'\')',
        function(a, b, c) {
            if (!b[0]) {
                client.query('INSERT INTO settings (id, data) VALUES (?, ?)', [config.room, JSON.stringify(config)],
                    function (a) { if (a) throw a;Log("Saved settings"); }
                );
            } else {
                client.query('UPDATE settings SET data="?" WHERE id="'+config.room+'"',
                    [JSON.stringify(config)],
                function (a) { if (a) throw a;Log("Saved settings"); }
            );
            }
        }
    );

and that seems to work. However, when I try to load it after I change something, and it saves, I get an error. This is the loading code:

    client.query('SELECT data FROM settings WHERE (id = \''+ config.room +'\')',
        function(a, b, c) {
            console.log(b.length);
            if (a) return console.log(a);
            if (!b[0]) return db.save("settings");
            console.log(b[0].data);
            config = JSON.parse(b[0].data);
            Log("Loaded Settings");
        }
    );

As you can see, all I'm really doing is calling JSON.parse() of the object I just stringified earlier. Yet I'm getting an error. The error is

undefined:1
3Th0seB310W","ui
^
SyntaxError: Unexpected token '

but there isn't a ' in the area where it's talking about. If you refer to the object up there.

These are the results form console.log(b[0].data): http://snippi.com/s/tknlgyo

Any help would be appreciated, and I'll add more info if it's needed. Note: the auth code has obviously been changed, but it's just a hex value like the uid below it, just longer.

The output of console.log has single quotes. That means the string you are trying to parse has them. Strip them before parsing.

For example, here is a a session using node:

> console.log("abc")
abc

The snippet you posted showed the single quotes. node did not put them there, so they must have gotten in your data somehow earlier. Make sure to suppress those when you generate and store your string.