Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
jsonobject.c
Go to the documentation of this file.
1
class
JsonObject
2
{
3
ref
map<string, string>
m_Strings
;
4
ref
map<string, int>
m_Ints
;
5
ref
map<string, float>
m_Floats
;
6
ref
map<string, bool>
m_Bools
;
7
ref
map<string, ref Vector2>
m_Vectors2
;
8
9
void
JsonObject
()
10
{
11
m_Strings
=
new
map<string, string>
;
12
m_Ints
=
new
map<string, int>
;
13
m_Floats
=
new
map<string, float>
;
14
m_Bools
=
new
map<string, bool>
;
15
m_Vectors2
=
new
map<string, ref Vector2>
;
16
}
17
18
void
~JsonObject
()
19
{
20
Clear
();
21
}
22
23
void
Clear
()
24
{
25
m_Strings
.Clear();
26
m_Ints
.Clear();
27
m_Floats
.Clear();
28
m_Bools
.Clear();
29
m_Vectors2
.Clear();
30
}
31
32
void
AddString
(
string
name
,
string
value)
33
{
34
array<string>
strgs =
new
array<string>
;
35
value.
Split
(
"\""
, strgs);
36
37
if
( strgs.Count() > 1 )
38
{
39
value =
""
;
40
int
str_count = strgs.Count();
41
42
for
(
int
i = 0; i < str_count; ++i )
43
{
44
string
s = strgs[i];
45
46
int
length = s.
Length
();
47
48
if
( s[length - 1] !=
"\\"
)
49
{
50
value += s;
51
52
if
(i < str_count - 1 )
53
{
54
value +=
"\\"
;
55
value +=
"\""
;
56
}
57
}
58
}
59
}
60
61
m_Strings
.Insert(
name
, value);
62
}
63
64
void
AddInt
(
string
name
,
int
value)
65
{
66
m_Ints
.Insert(
name
, value);
67
}
68
69
void
AddFloat
(
string
name
,
float
value)
70
{
71
m_Floats
.Insert(
name
, value);
72
}
73
74
void
AddBool
(
string
name
,
bool
value)
75
{
76
m_Bools
.Insert(
name
, value);
77
}
78
79
void
AddVector2
(
string
name
,
float
x
,
float
y
)
80
{
81
Vector2
v =
new
Vector2
(
x
,
y
);
82
m_Vectors2
.Insert(
name
, v);
83
}
84
85
string
GetJson
()
86
{
87
string
name
;
88
int
i;
89
90
string
jsn =
""
;
91
jsn +=
"{"
;
92
93
// Parse Strings
94
int
nStrings =
m_Strings
.Count();
95
for
( i = 0; i < nStrings; ++i )
96
{
97
if
( jsn.
Length
() > 1 )
98
{
99
jsn +=
","
;
100
}
101
102
name
=
m_Strings
.GetKey(i);
103
string
value_str =
m_Strings
.GetElement(i);
104
105
jsn +=
"\""
+
name
+
"\":\""
+value_str+
"\""
;
106
}
107
108
// Parse Ints
109
int
nInts =
m_Ints
.Count();
110
for
( i = 0; i < nInts; ++i )
111
{
112
if
( jsn.
Length
() > 1 )
113
{
114
jsn +=
","
;
115
}
116
117
name
=
m_Ints
.GetKey(i);
118
int
value_int =
m_Ints
.GetElement(i);
119
120
jsn +=
"\""
+
name
+
"\":"
+value_int;
121
}
122
123
// Parse Floats
124
int
nFloats =
m_Floats
.Count();
125
for
( i = 0; i < nFloats; ++i )
126
{
127
if
( jsn.
Length
() > 1 )
128
{
129
jsn +=
","
;
130
}
131
132
name
=
m_Floats
.GetKey(i);
133
float
value_flt =
m_Floats
.GetElement(i);
134
135
jsn +=
"\""
+
name
+
"\":"
+value_flt;
136
}
137
138
// Parse Bools
139
int
nBools =
m_Bools
.Count();
140
for
( i = 0; i < nBools; ++i )
141
{
142
if
( jsn.
Length
() > 1 )
143
{
144
jsn +=
","
;
145
}
146
147
name
=
m_Bools
.GetKey(i);
148
149
if
(
m_Bools
.GetElement(i) )
150
{
151
jsn +=
"\""
+
name
+
"\":true"
;
152
}
153
else
154
{
155
jsn +=
"\""
+
name
+
"\":false"
;
156
}
157
}
158
159
// Parse Vectors2
160
int
nVectors2 =
m_Vectors2
.Count();
161
for
( i = 0; i < nVectors2; ++i )
162
{
163
if
( jsn.
Length
() > 1 )
164
{
165
jsn +=
","
;
166
}
167
168
name
=
m_Vectors2
.GetKey(i);
169
Vector2
value_vct =
m_Vectors2
.GetElement(i);
170
171
jsn +=
"\""
+
name
+
"\":{\"x\":"
+value_vct.
x
+
",\"y\":"
+value_vct.
y
+
"}"
;
172
}
173
174
jsn +=
"}"
;
175
176
return
jsn;
177
}
178
};
name
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
JsonObject::JsonObject
void JsonObject()
Definition
jsonobject.c:9
JsonObject::AddFloat
void AddFloat(string name, float value)
Definition
jsonobject.c:69
JsonObject::AddBool
void AddBool(string name, bool value)
Definition
jsonobject.c:74
JsonObject::m_Bools
ref map< string, bool > m_Bools
Definition
jsonobject.c:6
JsonObject::AddInt
void AddInt(string name, int value)
Definition
jsonobject.c:64
JsonObject::m_Ints
ref map< string, int > m_Ints
Definition
jsonobject.c:4
JsonObject::~JsonObject
void ~JsonObject()
Definition
jsonobject.c:18
JsonObject::m_Floats
ref map< string, float > m_Floats
Definition
jsonobject.c:5
JsonObject::AddString
void AddString(string name, string value)
Definition
jsonobject.c:32
JsonObject::Clear
void Clear()
Definition
jsonobject.c:23
JsonObject::AddVector2
void AddVector2(string name, float x, float y)
Definition
jsonobject.c:79
JsonObject::m_Vectors2
ref map< string, ref Vector2 > m_Vectors2
Definition
jsonobject.c:7
JsonObject::GetJson
string GetJson()
Definition
jsonobject.c:85
JsonObject::m_Strings
ref map< string, string > m_Strings
Definition
jsonobject.c:3
Vector2
Definition
vector2.c:2
Vector2::y
float y
Definition
vector2.c:10
Vector2::x
float x
Definition
vector2.c:9
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition
isboxcollidinggeometryproxyclasses.c:28
map
Definition
cachedequipmentstorage.c:4
string::Split
void Split(string sample, out array< string > output)
Splits string into array of strings separated by 'sample'.
Definition
enstring.c:396
string::Length
proto native int Length()
Returns length of string.
x
Icon x
y
Icon y
Games
Dayz
scripts
3_game
tools
jsonobject.c
Generated by
1.17.0