Last active
August 23, 2021 13:02
-
-
Save JoeGlines/18ffbaa31fcad6767728a59664462d80 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;be sure to use 32-bit AutoHotkey | |
ParseJSON(jsonStr){ | |
static SC:=ComObjCreate("ScriptControl"),C:=Chr(125) | |
SC.Language:="JScript",ComObjError(0),SC.ExecuteStatement("function arrangeForAhkTraversing(obj){if(obj instanceof Array){for(var i=0; i<obj.length; ++i)obj[i]=arrangeForAhkTraversing(obj[i]);return ['array',obj];" C "else if(obj instanceof Object){var keys=[],values=[];for(var key in obj){keys.push(key);values.push(arrangeForAhkTraversing(obj[key]));" C "return ['object',[keys,values]];" C "else return [typeof obj,obj];" C ";obj=" jsonStr) | |
return convertJScriptObjToAhks(SC.Eval("arrangeForAhkTraversing(obj)")) | |
}ConvertJScriptObjToAhks(JSObj){ | |
if(JSObj[0]="Object"){ | |
Obj:=[],Keys:=JSObj[1][0],Values:=JSObj[1][1] | |
while(A_Index<=Keys.length) | |
Obj[Keys[A_Index-1]]:=ConvertJScriptObjToAhks(Values[A_Index-1]) | |
return Obj | |
}else if(JSObj[0]="Array"){ | |
Array:=[] | |
while(A_Index<=JSObj[1].length) | |
Array.Push(ConvertJScriptObjToAhks(JSObj[1][A_Index-1])) | |
return Array | |
}else | |
return JSObj[1] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It doesn't. Use 32 bit