So we have learned a little about:
- What JSON is
- quoting in JSON
- the difference between an object and a JSON string
Actually, I guess I should point out it’s not just objects, any data structure can be “an object”. A JSON file could contain, for instance:
["a", "b", "c"]
That’s an array of strings. If you JSON.stringify
that, you get:
let array = ["a", "b", "c"] let jsonArray = JSON.stringify(array) jsonArray // that returns "[\"a\",\"b\",\"c\"]"
Look, it’s weird. The only way to really internalize it is to screw up a lot going back and forth between files, data structures, objects, JSON strings, etc.
Now, why am I blathering on about this?
Because localStorage
.