Skip to content

Instantly share code, notes, and snippets.

@Sysetup
Last active November 3, 2017 05:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sysetup/ea408d64a911029b1d2889058ef72bf7 to your computer and use it in GitHub Desktop.
Save Sysetup/ea408d64a911029b1d2889058ef72bf7 to your computer and use it in GitHub Desktop.
Circular structure to JSON
https://stackoverflow.com/a/31557814/3363138
function simpleStringify(object) {
var simpleObject = {};
for (var prop in object) {
if (!object.hasOwnProperty(prop)) {
continue;
}
if (typeof (object[prop]) == 'object') {
continue;
}
if (typeof (object[prop]) == 'function') {
continue;
}
simpleObject[prop] = object[prop];
}
return JSON.stringify(simpleObject); // returns cleaned up JSON
};
var xxx = simpleStringify(valuex)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment