I am working on a project that requires an object to have multiple values. For instance, a list of ‘things’ all with a name but each thing also has another category, “Tags” with could include things like round, circle, ball, sport, etc. all words describing what the ‘thing’ is. I am trying to define this in JSON but I keep running into errors with jsonlint. Take a look:
{
"things":[{
"name":"thing1",
"tags":[{"globe","circle","round","world"}]
},
{
"name":"thing2",
"tags":[{"cloud","weather","lightning","sky"}]
},
{
"name":"thing3",
"tags":[{"round","bullseye","target"}]
},
{
"name":"thing4",
"tags":[{"round","key","lock"}]
},
{
"name":"thing5",
"tags":[{"weather","sun","sky","summer"}]
}]
}
Hopefully you see what I am trying to accomplish.
Thanks for your help!
Anthony
Your “tags” objects seem off to me. The code:
would try to create an array of an object whose properties don’t have any values, but I’m not sure that’s even valid syntax. Do you want an array of words for “tags?” If so, you need to drop those curly braces:
That would give you an object with property “things” that contains an array of one object with a “name” and a “tags” property, where “tags” is an array of words.
You could access “tags” like so: