Hi all,
I’ve been using the Mustache.js templating system for the past few days, exciting stuff!
The problem is, I have a third party JSON file with some serious deep level nesting with arrays etc. having a little trouble trying to access the values I need.
Reduced for viewing
{
"question":{
"query":"podcasts",
"collection":{ },
"originalQuery":"podcasts",
},
"response":{
"resultPacket":{
"details":{ },
"query":"podcasts",
"results":[
{
"rank":1,
"score":10,
"title":"example title of podcast",
"meta":{
"filetype":"mp3",
"keywords":"abd,def,xyz"
}
},
{
"rank":2,
"score":35,
"title":"example title two of podcast",
"meta":{
"filetype":"mp3",
"keywords":"abd,def,xyz"
}
},
{
"rank":3,
"score":18,
"title":"example title three of podcast",
"meta":{
"filetype":"mp3",
"keywords":"abd,def,xyz"
}
},
]
}
},
}
I need to loop through the results
set within response
and display the title
value and values inside the meta
array.
How do I do this?
I currently have:
<script id="resultstpl" type="text/template">
<div class="container">
{{#question}}
<p>{{query}}</p>
{{/question}}
</div>
</script>
Which prints podcasts
though I need to access the results array.
Update: Added a codepen if this helps - https://codepen.io/anon/pen/wyVoOa
Any examples appreciated
Thanks, Barry