I can not post the correct result. There is a JSON file and you need to output this using cycles:
<div class="inner"> <span class="f_text">this 1</span> <span class="f_pos">ΠΌΠ΅ΡΡΠΎΠΈΠΌΠ΅Π½ΠΈΠ΅ 1</span> <span class="f_ts">Γ°Ιͺs 1</span> <span class="l_text">ΡΡΠΎΡ 2</span> <span class="l_pos">ΠΌΠ΅ΡΡΠΎΠΈΠΌΠ΅Π½ΠΈΠ΅ 2</span> </div> <div class="inner"> <span class="f_text">this 1</span> <span class="f_pos">ΡΠ°ΡΡΠΈΡΠ° 1</span> <span class="f_ts">Γ°Ιͺs 1</span> <span class="l_text">ΡΡΠΎ 2</span> <span class="l_pos">ΡΠ°ΡΡΠΈΡΠ° 2</span> </div> <div> <span class="f_text">this 1</span> <span class="f_pos">ΠΏΡΠΈΠ»Π°Π³Π°ΡΠ΅Π»ΡΠ½ΠΎΠ΅ 1</span> <span class="f_ts">Γ°Ιͺs 1</span> <span class="l_text">Π½Π°ΡΡΠΎΡΡΠΈΠΉ 2</span> <span class="l_pos">ΠΏΡΠΈΠ»Π°Π³Π°ΡΠ΅Π»ΡΠ½ΠΎΠ΅ 2</span> </div> JSON file:
{ "head": {}, "def": [{ "text": "this", "pos": "ΠΌΠ΅ΡΡΠΎΠΈΠΌΠ΅Π½ΠΈΠ΅", "ts": "Γ°Ιͺs", "tr": [{ "text": "ΡΡΠΎΡ", "pos": "ΠΌΠ΅ΡΡΠΎΠΈΠΌΠ΅Π½ΠΈΠ΅", "syn": [{ "text": "ΡΠ°ΠΊΠΎΠΉ", "pos": "ΠΌΠ΅ΡΡΠΎΠΈΠΌΠ΅Π½ΠΈΠ΅" }, { "text": "ΡΠ΅ΠΉ", "pos": "ΠΌΠ΅ΡΡΠΎΠΈΠΌΠ΅Π½ΠΈΠ΅" }], "mean": [{ "text": "the" }, { "text": "still" }] }] }, { "text": "this", "pos": "ΡΠ°ΡΡΠΈΡΠ°", "ts": "Γ°Ιͺs", "tr": [{ "text": "ΡΡΠΎ", "pos": "ΡΠ°ΡΡΠΈΡΠ°" }] }, { "text": "this", "pos": "ΠΏΡΠΈΠ»Π°Π³Π°ΡΠ΅Π»ΡΠ½ΠΎΠ΅", "ts": "Γ°Ιͺs", "tr": [{ "text": "Π½Π°ΡΡΠΎΡΡΠΈΠΉ", "pos": "ΠΏΡΠΈΠ»Π°Π³Π°ΡΠ΅Π»ΡΠ½ΠΎΠ΅", "syn": [{ "text": "ΠΏΠΎΠ΄ΠΎΠ±Π½ΡΠΉ", "pos": "ΠΏΡΠΈΠ»Π°Π³Π°ΡΠ΅Π»ΡΠ½ΠΎΠ΅" }, { "text": "Π½ΡΠ½Π΅ΡΠ½ΠΈΠΉ", "pos": "ΠΏΡΠΈΠ»Π°Π³Π°ΡΠ΅Π»ΡΠ½ΠΎΠ΅" }], "mean": [{ "text": "present" }, { "text": "such" }, { "text": "current" }], "ex": [{ "text": "this button", "tr": [{ "text": "Π½Π°ΡΡΠΎΡΡΠ°Ρ ΠΊΠ½ΠΎΠΏΠΊΠ°" }] }] }] }] } My javascript code is:
var output = ""; var main_div = document.createElement("div"); main_div.setAttribute('id', "main"); document.body.appendChild(main_div); for (var i = 0; i < info["def"].length; i++) { var inner_div = document.createElement('div'); inner_div.className = "inner"; var res = main_div.appendChild(inner_div); for (var j = 0; j < info["def"][i]["tr"].length; j++) { for (var key in info["def"][i]) { if (info["def"][i].hasOwnProperty(key) && typeof info["def"][i][key] != "object") { output += '<span class=f_' + key + '>' + info["def"][i][key] + " " + ' 1</span>'; } } for (var key2 in info["def"][i]["tr"][j]) { if (info["def"][i]["tr"][j].hasOwnProperty(key2) && typeof info["def"][i]["tr"][j][key2] != "object") { output += '<span class=l_' + key2 + '>' + info["def"][i]["tr"][j][key2] + " " + ' 2</span>'; } } } //for each object res.insertAdjacentHTML('afterBegin', output); }