Im Trying to accesss to 'dataset' in 'protocol1' or to 'zeile' which is in 'log' which is in 'protocol1'. But i cant get make it working.
I tried it with nested for loops but i dont work.
This is my JSON File.
{
"data": [
{
"protocol1": {
"dataset": "Testdataset1",
"eingangssprache": "Testeingangssprache1",
"ausgangssprache": "Testausgangssprache1",
"start": "13/01/2021 04:22 1",
"end": "14/01/2021 16:20 1"
},
"log": [
{
"zeile": "01",
"methode": "lang detect",
"language1": "german",
"language2": "english"
},
{
"zeile": "02",
"methode": "lang detect",
"language1": "german",
"language2": "english"
},
{
"zeile": "03",
"methode": "lang detect",
"language1": "german",
"language2": "english"
}
]
},
{
"protocol2": {
"dataset": "Testdataset2",
"eingangssprache": "Testeingangssprache1",
"ausgangssprache": "Testausgangssprache1",
"start": "13/01/2021 04:22 1",
"end": "14/01/2021 16:20 1"
},
"log": [
{
"zeile": "01",
"methode": "lang detect es",
"language1": " es",
"language2": "english es"
},
{
"zeile": "01",
"methode": "lang detect",
"language1": "german es",
"language2": "engli essh"
},
{
"zeile": "01",
"methode": "lang dete esct",
"language1": "germa esn",
"language2": "engli essh"
}
]
}
]
}
Does maybe someone know how? Im using flask which is jinja2.
Before it was like this
{
"data": [
{
"ausgangssprache": "Testout",
"dataset": "Test",
"eingangssprache": "Testin",
"end": "14/01/2021 00:00",
"start": "13/01/2021 04:22",
"zeile": "45",
"methode": "language detection",
"language1": "Testin",
"language2": "TestLlang",
"zusammenfassung": "Zsf"
}
]
}
And i could get access this JSON with this html code
{% for i in data_protocol %}
<tr>
<td>{{ i.dataset }}</td>
<td>{{ i.eingangssprache }}</td>
<td>{{ i.ausgangssprache }}</td>
<td>{{ i.start }}</td>
<td>{{ i.end }}</td>
<td>
......stuff ...
{% endfor %}
the python code which is returning the json file is this
json_file = open("data/table.json", "r")
data = json.load(json_file)
json_file.close()
data = data['data']
return render_template('index.html',
column_names=['Dataset', 'Eingangssprache', 'Ausgangssprache', 'Startzeit', 'Endzeit', 'LOG'],
data_protocol=data)
I hope you can help me with that, thanks in advance