Last active
November 3, 2017 05:00
-
-
Save Sysetup/ea408d64a911029b1d2889058ef72bf7 to your computer and use it in GitHub Desktop.
Circular structure to JSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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