In my possession is a JSON file with the following data:
[
{
“name”: “Joshia \”Placement\” Fonz”,
“color”: “white”
},
{
"name": “Trin Brin”,
“color”: “black”
},
{
“name”: “Su Et”,
“color”: “yellow”
}
]
I am looking to extract and utilize the array and objects within this file for my application. With './students.json'
as the file path, I first tried using JSON.parse('./students.json')
. Unfortunately, this resulted in an error message stating:
Uncaught SyntaxError: Unexpected token . in JSON at position 0
. Subsequently, I attempted JSON.stringify('./students.json')
, only to receive the original string of the path './students.json'
.
Could you please advise on how I can successfully parse this JSON file in Javascript to access the array?
Thank you.