forked from cocobelgica/AutoHotkey-JSON
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExample_JSON.ahk
49 lines (44 loc) · 907 Bytes
/
Example_JSON.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#Include %A_LineFile%\..\JSON.ahk
json_str =
(
{
"str": "Hello World",
"num": 12345,
"float": 123.5,
"true": true,
"false": false,
"null": null,
"array": [
"Auto",
"Hot",
"key"
],
"object": {
"A": "Auto",
"H": "Hot",
"K": "key"
}
}
)
parsed := JSON.Load(json_str)
parsed_out := Format("
(Join`r`n
String: {}
Number: {}
Float: {}
true: {}
false: {}
null: {}
array: [{}, {}, {}]
object: {{}A:""{}"", H:""{}"", K:""{}""{}}
)"
, parsed.str, parsed.num, parsed.float, parsed.true, parsed.false, parsed.null
, parsed.array[1], parsed.array[2], parsed.array[3]
, parsed.object.A, parsed.object.H, parsed.object.K)
stringified := JSON.Dump(parsed,, 4)
stringified := StrReplace(stringified, "`n", "`r`n") ; for display purposes only
ListVars
WinWaitActive ahk_class AutoHotkey
ControlSetText Edit1, [PARSED]`r`n%parsed_out%`r`n`r`n[STRINGIFIED]`r`n%stringified%
WinWaitClose
return