Created
February 25, 2017 11:21
-
-
Save hirokiky/aefb4317884480fa10e92163b2f59a2a to your computer and use it in GitHub Desktop.
Jsonify tree objects
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
toJson() { | |
return JSON.stringify(this, (key, value) => { | |
if (key == 'parent') { | |
return value.id; | |
} else { | |
return value; | |
} | |
}); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment