If I have a JSON
file named names.json with:
{\"employees\":[
{\"firstName\":\"Anna\",\"lastName\":\"Meyers\"},
{\"firstNam
You can simply include a Javascript file in your HTML that declares your JSON object as a variable. Then you can access your JSON data from your global Javascript scope using data.employees
, for example.
index.html:
data.js:
var data = {
"employees": [{
"firstName": "Anna",
"lastName": "Meyers"
}, {
"firstName": "Betty",
"lastName": "Layers"
}, {
"firstName": "Carl",
"lastName": "Louis"
}]
}