I have a JSON file containing data that I want to read in Javascript instead of hard-coding them in code (more than 3000 lines).
I tried referencing JSON in HTML and using it but returned an empty array
In HTML:
<script type="file" src="data.json"></script>
In javascript:
console.log(JSON.parse(data))
I get back an empty array rather than the data.
data.jsonfile that starts with{or[and respectively ends with},], simply addvar data =in front of the file. And import the file as a script and just use it as a JS variable.