I have a JSON file similar to the following:
[
"thing1",
"thing2",
"thing3",
]
Let's call this file some-things.json
.
I have a JavaScript file in the same directory as this JSON. I need the JSON data to be read in as an array, used elsewhere in the JavaScript.
What's the best way to do this? Do I have to read the JSON into a string and then parse to an array, or is there a nicer way? For example, array = ReadJSONArray('some-things.json')
.
I have looked for duplicates, but I haven't found any questions where the JSON is in a file, not a string.
Also, as stated in the question title, I don't want to use JQuery for this. I have seen a few questions on SO where people have asked this question, but tagged as and/or mentioning JQuery.