Created
May 11, 2017 12:11
-
-
Save Quinten/9a9877025ce6db25d2fbad5c54c94008 to your computer and use it in GitHub Desktop.
Download any javascript object as json file
This file contains hidden or 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
var data = {test: 'test'}; | |
var dataUri = 'data:application/json;charset=utf-8,'+ encodeURIComponent(JSON.stringify(data)); | |
var link = document.createElement("a"); | |
link.download = 'export.json'; | |
link.href = dataUri; | |
document.body.appendChild(link); | |
link.click(); | |
document.body.removeChild(link); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment