-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathLitJsonUtils.js
63 lines (52 loc) · 1022 Bytes
/
LitJsonUtils.js
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
#pragma strict
import System.Text;
import LitJson;
/* Utilities for using LitJson */
class MyJsonWriter extends JsonWriter
{
public function MyJsonWriter( sb:StringBuilder )
{
super(sb);
}
public function Write( v:Vector3 )
{
this.WriteArrayStart();
this.Write(v.x);
this.Write(v.y);
this.Write(v.z);
this.WriteArrayEnd();
}
public function Write( v:Vector2 )
{
this.WriteArrayStart();
this.Write(v.x);
this.Write(v.y);
this.WriteArrayEnd();
}
// Shortcuts for properties
public function Write( prop:String, v:Vector3 )
{
WritePropertyName(prop);
Write(v);
}
public function Write( prop:String, v:Vector2 )
{
WritePropertyName(prop);
Write(v);
}
public function Write( prop:String, v:float )
{
WritePropertyName(prop);
Write(v);
}
}
class ToStringJsonWriter extends MyJsonWriter
{
private var sb = null;
public function ToStringJsonWriter()
{
sb = new StringBuilder();
super(sb);
}
public function GetString() : String { return sb.ToString(); }
}