or Close Gui: Exit script.
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
Gui add, Edit, w500 h500 vEdt
Gui show
json=
(
[[["schlank","slim",null,null,2]
,[null,null,null,"slim"]
]
,[["adjective",["schlank","schmal","gering"]
,[["schlank",["slim","slender"]
,null,0.10874496]
,["schmal",["narrow","small","slim","thin","slender","lean"]
,null,0.020754337]
,["gering",["low","small","slight","little","minor","slim"]
,null,0.009354713]
]
,"slim",3]
,["verb",["schrumpfen","schlank machen"]
,[["schrumpfen",["shrink","shrivel","dwindle","atrophy","slim","depreciate"]
,null,7.722788E-5]
,["schlank machen",["slim","slenderize"]
,null,7.485183E-5]
]
,"slim",2]
]
,"en",null,null,[["slim",null,[["schlank",1000,true,false]
]
,[[0,4]
]
,"slim",0,0]
]
,0.86985385,[]
,[["en"]
,null,[0.86985385]
,["en"]
]
,null,null,[["verb",[[["lose weight","get thinner","lose/shed some pounds","lose some inches","get into shape","shape up","reduce","diet","go on a diet","slenderize"]
,"m_en_gbus0955300.022"]
,[["reduce","cut","cut down/back","make cutbacks in","scale down","trim","decrease","diminish","pare down","whittle away","prune","rationalize","downsize"]
,"m_en_gbus0955300.029"]
]
,"slim"]
,["adjective",[[["narrow","slender","slimline"]
,"m_en_gbus0955300.012"]
,[["slender","lean","willowy","sylphlike","svelte","lissom","graceful","snake-hipped","rangy","clean-limbed","trim","slight","slightly built","thin","as thin as a reed","skinny","size-zero","spare","attenuated","lanky","spindly"]
,"m_en_gbus0955300.008"]
,[["gracile","attenuate"]
,"m_en_gbus0955300.008"]
,[["slight","small","slender","faint","feeble","poor","flimsy","tenuous","fragile","negligible","marginal","minimal","outside","remote","distant","unlikely","improbable"]
,"m_en_gbus0955300.016"]
]
,"slim"]
]
,[["verb",[["make oneself thinner, especially by dieting.","m_en_gbus0955300.022","I need to slim down a bit"]
]
,"slim"]
,["adjective",[["(of a person or their build) gracefully thin; slenderly built (used approvingly).","m_en_gbus0955300.008","her slim figure"]
,["(of something abstract, especially a chance or margin) very small.","m_en_gbus0955300.016","there was just a slim chance of success"]
]
,"slim"]
,["noun",[["a course or period of slimming.","m_en_gbus0955300.032","a sponsored slim"]
,["a term used in parts of Africa to refer to AIDS.","m_en_gbus0955300.035"]
]
,"slim"]
]
,[[["the evidence is \u003cb\u003eslim\u003c/b\u003e",null,null,null,3,"m_en_gbus0955300.016"]
,["the girls were tall and \u003cb\u003eslim\u003c/b\u003e",null,null,null,3,"m_en_gbus0955300.008"]
,["a pair of \u003cb\u003eslim\u003c/b\u003e, immaculately cut slacks",null,null,null,3,"m_en_gbus0955300.013"]
,["her \u003cb\u003eslim\u003c/b\u003e figure",null,null,null,3,"m_en_gbus0955300.008"]
,["I need to \u003cb\u003eslim\u003c/b\u003e down a bit",null,null,null,3,"m_en_gbus0955300.022"]
,["a sponsored \u003cb\u003eslim\u003c/b\u003e",null,null,null,3,"m_en_gbus0955300.032"]
,["how can I \u003cb\u003eslim\u003c/b\u003e down my hips?",null,null,null,3,"m_en_gbus0955300.028"]
,["there was just a \u003cb\u003eslim\u003c/b\u003e chance of success",null,null,null,3,"m_en_gbus0955300.016"]
,["a \u003cb\u003eslim\u003c/b\u003e gold band encircled her wrist",null,null,null,3,"m_en_gbus0955300.012"]
]
]
]
)
GuiControl,, Edt, % txtJsn(json)
;GuiControl,, Edt, % prnJsn(json)
KeyWait Esc, D
KeyWait Esc
;============================================================
; exemp for having no line breaks
json= [[["schlank os gut","slim os good",null,null,3,null,null,[[],[]],[[["1814a2c300f02f227bcb04312cd2671a","tea_pt_en_2019q4.md"]],[["4d5e201a34474a12730540dc3bfae9fd","tea_en_de_2020q1.md"]]]]],null,"pt",null,null,[["slim os good",null,[["schlank os gut",0,true,false]],[[0,12]],"slim os good",0,0]],0.6054487,[],[["pt"],null,[0.6054487],["pt"]]]
GuiControl,, Edt, % txtJsn(json)
;GuiControl,, Edt, % prnJsn(json)
KeyWait Esc, D
KeyWait Esc
;============================================================
json=
(
[[["英語","English",null,null,2]
,[null,null,"Eigo","ˈiNG(ɡ)liSH"]
]
,[["noun",["英語","英国人"]
,[["英語",["English","English language"]
,null,0.47980523]
,["英国人",["English","Englishman"]
]
]
,"English",1]
,["adjective",["英国の","英語の"]
,[["英国の",["English","British"]
]
,["英語の",["English"]
]
]
,"English",3]
]
,"en",null,null,[["English",null,[["英語",1000,true,false]
]
,[[0,7]
]
,"English",0,0]
]
,1.0,[]
,[["en"]
,null,[1.0]
,["en"]
]
,null,null,null,[["adjective",[["relating to England or its people or language.","m_en_gbus0324780.005"]
]
,"English"]
,["noun",[["the language of England, widely used in many varieties throughout the world.","m_en_gbus0324780.010"]
,["the people of England.","m_en_gbus0324780.014"]
]
,"English"]
]
,[[["an \u003cb\u003eEnglish\u003c/b\u003e book",null,null,null,3,"neid_6195"]
,["her \u003cb\u003eEnglish\u003c/b\u003e is very good",null,null,null,3,"neid_6197"]
,["put that into \u003cb\u003eEnglish\u003c/b\u003e",null,null,null,3,"neid_6197"]
,["how do you say that in \u003cb\u003eEnglish\u003c/b\u003e?",null,null,null,3,"neid_6197"]
,["he's doing \u003cb\u003eEnglish\u003c/b\u003e at university",null,null,null,3,"neid_6197"]
,["say that in \u003cb\u003eEnglish\u003c/b\u003e",null,null,null,3,"neid_6197"]
,["she's \u003cb\u003eEnglish\u003c/b\u003e",null,null,null,3,"neid_6196"]
,["he speaks \u003cb\u003eEnglish\u003c/b\u003e",null,null,null,3,"neid_6197"]
,["\u003cb\u003eEnglish\u003c/b\u003e class",null,null,null,3,"neid_6195"]
,["\u003cb\u003eEnglish\u003c/b\u003e dictionary",null,null,null,3,"neid_6195"]
,["the \u003cb\u003eEnglish\u003c/b\u003e language",null,null,null,3,"neid_6195"]
,["\u003cb\u003eEnglish\u003c/b\u003e teacher",null,null,null,3,"neid_6195"]
,["they're speaking \u003cb\u003eEnglish\u003c/b\u003e",null,null,null,3,"neid_6197"]
,["what's the \u003cb\u003eEnglish\u003c/b\u003e for 'bia'?",null,null,null,3,"neid_6197"]
,["a film in \u003cb\u003eEnglish\u003c/b\u003e",null,null,null,3,"neid_6197"]
,["an \u003cb\u003eEnglish\u003c/b\u003e word",null,null,null,3,"neid_6195"]
,["she has a degree in \u003cb\u003eEnglish\u003c/b\u003e",null,null,null,3,"neid_6197"]
,["\u003cb\u003eEnglish\u003c/b\u003e exam",null,null,null,3,"neid_6195"]
]
]
]
)
GuiControl,, Edt, % txtJsn(json)
;GuiControl,, Edt, % prnJsn(json)
Return
GuiClose:
^Esc:: ExitApp
txtJsn(r, i:=" ", d:=0, b:="") { ; by RRR inspired by txtArr
loop, % IsObject(r)? r.length: (r:= CreateScriptObj().("(" r ")")).length
c.= IsObject(v:=r[k:=A_Index-1])? b k ":`n" txtJsn(v, i, d+1, b i): b k ": " v "`n", d>0? "": t:=c
Return d>0? c: t
}
prnJsn(r, i:=" ", d:=50, b:="") { ; by RRR inspired by prnArr
loop, % IsObject(r)? r.length: (r:= CreateScriptObj().("(" r ")")).length
l.= b (k:=A_Index-1) ": ", (IsObject(v:=r[k]) && d>1)? l.=(t:=prnJsn(v, i, d-1, b i))? "`n" t: "": l.=v, l.= "`n"
return RTrim(l, "`n")
}
CreateScriptObj() { ; by teadrinker
static doc
doc := ComObjCreate("htmlfile"), doc.write("<meta http-equiv='X-UA-Compatible' content='IE=9'>")
Return ObjBindMethod(doc.parentWindow, "eval")
}
This will work only for "flat" arrays (of any depth), not for "dictionarys" (associative arrays), but