John M
John M

Reputation: 197

vuejs nested json rendering

I am having to work with a json which looks like so:

 book_json={ "id": 2, "book": "Rockford mountain", "related_json": { "choice0": " The Good Friday Book", "choice1": "DRiven by Inspiration", "choice2": "Do good, be good", "choice3": "Autobiography Obama", "choice4": "None", "select0": "choice0", "select1": "None" } }

In my template, when I render:

{{book_json.book} or {{book_json.id}} # all good 

However, what I would like to display is:

{{book_json.related_json.{{book_json.related_json.select0}} }}
// result: `The Good Friday Book`

i.e I would like to pick choice0 which arises from {{book_json.related_json.select0}}

I have spent a few hours trying and googleing around, but could not find a way to do this..

Any tips to solve this issue would be much appreciated..

Upvotes: 0

Views: 148

Answers (1)

Mindastic
Mindastic

Reputation: 4121

Try with:

[[ book_json.related_json[book_json.related_json.select0] ]]

Upvotes: 1

Related Questions