-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjson.iss
More file actions
93 lines (72 loc) · 1.91 KB
/
Copy pathjson.iss
File metadata and controls
93 lines (72 loc) · 1.91 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include "isx/isx.iss"
[Setup]
AppName=testApp
AppVersion=1.0.0
DefaultDirName={pf}\testApp
[code]
procedure example1();
var
hJson: Integer;
a: Integer;
pi: Single;
greeting: AnsiString;
str: AnsiString;
begin
str := '{ "a":5, "foo":{ "greeting": "hello" }, "pi":3.141516 }';
if (not ISX_JsonParse(str, hJson)) then exit;
if (not ISX_JsonInt(hJson, 'a', 0, a)) then exit;
if (not ISX_JsonFloat(hJson, 'pi', 0, pi)) then exit;
if (not ISX_JsonString(hJson, 'foo.greeting', 0, greeting)) then exit;
a := 2*a;
pi := pi/2;
greeting := greeting + ' world !';
if (not ISX_JsonInt(hJson, 'a', 1, a)) then exit;
if (not ISX_JsonFloat(hJson, 'pi', 1, pi)) then exit;
if (not ISX_JsonString(hJson, 'foo.greeting', 1, greeting)) then exit;
if (not ISX_JsonStringify(hJson, str)) then exit;
Log(str); // {"a":10,"foo":{"greeting":"hello world !"},"pi":1.5707579851150513}
end;
procedure example2();
var
hArray: Integer;
i,a: Integer;
str: AnsiString;
count: Integer;
begin
ISX_JsonParse('[]', hArray);
for i := 0 to 10 do
begin
a := i*10;
ISX_JsonIntFromIdx(hArray, i, 1, a);
end;
ISX_JsonStringify(hArray, str);
Log(str); // [0,10,20,30,40,50,60,70,80,90,100]
count := ISX_JsonSize(hArray)
ISX_JsonIntFromIdx(hArray, count/2, 0, a);
Log(IntToStr(a)) // 50
end;
procedure example3();
var
hJson: Integer;
j1, j2, j3: Integer;
str: AnsiString;
begin
ISX_JsonParse('{}',hJson);
ISX_JsonParse('{"a":1, "b":2}', j1);
ISX_JsonObj(hJson, 'A', 1, j1);
ISX_JsonParse('{"c":1, "d":2}', j2);
ISX_JsonObj(hJson, 'B', 1, j2);
ISX_JsonStringify(hJson, str);
Log(str); // {"A":{"a":1,"b":2},"B":{"c":1,"d":2}}
ISX_JsonObj(hJson, 'B', 0, j3);
ISX_JsonStringify(j3, str);
Log(str); // {"c":1,"d":2}
end;
function InitializeSetup(): Boolean;
begin
Result := ISX_InitializeSetup(false);
example1();
example2();
example3();
Result := False;
end;