I am new to json, and I have a nested json object called jresult in django view.py. I passed this object to html and I wanna display it in html.
in view.py:
return render(request,'home.html', {'jresult': jresult})
jresult:
{
"company": "xxx",
"address": "xxx",
"ceo": "xxx,
"employee": {
"Emily": {
"id": "xxx",
"gender": "xxx"
},
"Tom": {
"id": "xxx",
"gender": "xxx"
},
"Alex": {
"id": "xxx",
"gender": "xxx"
},
},
}
So far I can only loop through the employee's name and display them in the html page: Emily, Tom and Alex by the following html code:
{% for obj in jresult.employee %}
<p>{{obj}}</p>
{% endfor %}
how can I access the id and gender as well, I have tried
{% for obj in jresult.employee %}
<p>{{obj}}</p>
{% for item in jresult.employee.obj.gender %}
<p>{{item}}</p>
{% endfor %}
{% endfor %}
but it doesn't work. Any helps will be appreciated.
django. You'll have better luck if you alter your question and tags to include the templating you're using that interprets that syntax.