-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjson.prg
More file actions
executable file
·53 lines (42 loc) · 1.02 KB
/
Copy pathjson.prg
File metadata and controls
executable file
·53 lines (42 loc) · 1.02 KB
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
50
51
52
53
DO (GETENV("userprofile") + "\Kawix\Shide\interop")
local json1, json2 , lib
PUBLIC result1, result2
TEXT TO m.json1 NOSHOW
{
"image": {
"width": 800,
"height": 600,
"title": "View from 15th Floor",
"thumbnail": {
"url": "http://www.example.com/image/481989943",
"height": 125,
"width": 100
},
"visible": true,
"ids": [116, 943, 234, 38793]
}
}
ENDTEXT
TEXT TO m.json2 NOSHOW
[
1,
2,
[3, 4, 5, 6],
{
"id": 1,
"name": "A wooden door",
"price": 12.50,
"tags": ["home", "wooden"]
}
]
ENDTEXT
lib = _screen.nodeinterop.loadlibrary("json.parse")
* you can put a breakpoint here, to inspect the variables
result1 = lib.parse(m.json1)
result2 = lib.parse(m.json2)
* probe first result
MESSAGEBOX(m.result1.image.title)
MESSAGEBOX(m.result1.image.thumbnail.url)
* second result is a collection (json arrays are transformed to collections)
MESSAGEBOX(m.result2.item[1])
MESSAGEBOX(m.result2.item[4].name)