Saves the given data
as a json file to the downlaods folder of the browser. The default file name is export.json
but you can give another name as the second argument. pretty
set to false will save a file without line breaks which makes it a bit smaller but also less legible.
If this is your data:
let superheroes = [
{Name: "Superboy", Height: 170, Weight: 68},
{Name: "Supergirl", Height: 165, Weight: 54},
{Name: "Superman", Height: 191, Weight: 101}
]
gmynd.saveData(superheroes);
... gives you this result in the file export.json
:
[{
"Name":"Superboy",
"Height":170,
"Weight":68
},{
"Name":"Supergirl",
"Height":165,
"Weight":54
},{
"Name":"Superman",
"Height":191,
"Weight":101
}]
gmynd.saveData(superheroes, 'heroes.json', false)
... gives you this result in the file heroes.json
:
[{"Name":"Superboy","Height":170,"Weight":68},{"Name":"Supergirl","Height":165,"Weight":54},{"Name":"Superman","Height":191,"Weight":101}]