I've been experimenting with writing functions within JSON files, but I keep encountering errors related to 'unexpected tokens'. Below is a snippet of the JSON code I'm working with:
[
{
"thumb": "./templates/scripts/thumbs/01.jpg",
"get": function() {
console.log('mthood');
},
"title": "Mt. Hood Sunset",
"desc": "A peaceful view of Mt. Hood, Oregon."
},
{
"thumb": "./templates/scripts/thumbs/02.jpg",
"get": function() {
console.log('misty');
},
"title": "Misty Rainforest",
"desc": "Lush and damp surroundings."
},
{
"thumb": "./templates/scripts/thumbs/03.jpg",
"get": function() {
console.log('clouds');
},
"title": "Clouds",
"desc": "Clear blue skies with fluffy white clouds."
}
]
As displayed by JSONLint, a more elaborate error message pops up that I find a bit puzzling:
Error: Parse error on line 5:
...s/01.jpg", "get": function() { cons
----------------------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'undefined'
Does anyone have any thoughts or suggestions for resolving this issue?