I have a javascript that creates and saves a json file wich contains a list of objects:
let Animal = {
legs: "",
color: "",
};
let arr[];
let me = Object.create(Animal);
me.legs = "a";
me.color = "b";
arr.push(me);
window.localStorage.setItem("example", JSON.stringify(arr));
exportA();
function exportA()
{
const a = document.createElement("a");
a.href = URL.createObjectURL(
new Blob([JSON.stringify(window.localStorage.getItem("example"), null, 2)], {
type: "text/json"
}));
a.setAttribute("download", "examplefile.json");
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
}
All things works fine. When I open the created file with text editor I get following output: "[{"legs":"a","color":"b"}]"
Serveral online validators and my browsers confirms the json content as valid.
My expected output is: [{"legs":"a","color":"b"}]
. My question is, what do I miss to create the expected output of a list or is it just a mistake of thinking?