function safeStringify(obj) {
        var seen = [];
        return JSON.stringify(obj, function (key, value) {
            if (types_1.isObject(value) || Array.isArray(value)) {
                if (seen.indexOf(value) !== -1) {
                    return '[Circular]';
                }
                else {
                    seen.push(value);
                }
            }
            return value;
        });
    }
Calls JSON.Stringify with a replacer to break apart any circular references.
This prevents JSON.stringify from throwing the exception
 "Uncaught TypeError: Converting circular structure to JSON"