Reputation: 185
Im trying to select a category from a json file and use it to show the representing value of that category.
{
"truth": [
{
"id": "dd33b9c4-c3ef-11e8-b8dc-8b77bf3680b2",
"value": "bla bla",
"category": "funny",
"appeared": false
}
]
"dare": [
{
"id": "dd33b9c4-c3ef-11e8-b8dc-8b77bf3680b2",
"value": "bla bla",
"category": "funny",
"appeared": false
}
]
}
<select>
<option value={[truth].category}></option>
</select>
Thanks for the help.
Upvotes: 0
Views: 432
Reputation: 3458
I would suggest to use Angular or a different library to accomplish this. Take a look at following: Angular
With the help of this frontend HTTP library you are able to build UI's based on HTML and connect them to the data model thats in your case the JSON object.
Upvotes: 0
Reputation: 261
You have to use index of object that you are trying to access in truth array like this
truth[0].category
Upvotes: 1