-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathJsonEx.py
49 lines (39 loc) · 1.18 KB
/
JsonEx.py
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
# Nikita Akimov
#
# GitHub
# https://github.com/Korchy/BIS
class JsonEx:
@staticmethod
def vector2_to_json(vector):
return [vector.x, vector.y]
@staticmethod
def vector2_from_json(vector, vector_in_json):
vector.x = vector_in_json[0]
vector.y = vector_in_json[1]
@staticmethod
def vector3_to_json(vector):
return [vector.x, vector.y, vector.z]
@staticmethod
def vector3_from_json(vector, vector_in_json):
vector.x = vector_in_json[0]
vector.y = vector_in_json[1]
vector.z = vector_in_json[2]
@staticmethod
def prop_array_to_json(prop_array):
rez = []
for prop in prop_array:
rez.append(prop)
return rez
@staticmethod
def prop_array_from_json(prop_array, prop_array_in_json):
for i, prop in enumerate(prop_array_in_json):
prop_array[i] = prop
@staticmethod
def color_to_json(color):
return [color.r, color.g, color.b]
@staticmethod
def color_from_json(color, color_in_json):
color.r = color_in_json[0]
color.g = color_in_json[1]
color.b = color_in_json[2]