|
@@
-87,36
+87,54
namespace Implab.JSON {
|
|
87
|
}
|
|
87
|
}
|
|
88
|
|
|
88
|
|
|
89
|
public void WriteValue(string value) {
|
|
89
|
public void WriteValue(string value) {
|
|
90
|
if (m_context.element != JSONElementContext.Array)
|
|
90
|
if (m_context.element == JSONElementContext.Array) {
|
|
91
|
OperationNotApplicable("WriteValue");
|
|
91
|
|
|
92
|
if (m_context.needComma)
|
|
92
|
if (m_context.needComma)
|
|
93
|
m_writer.Write(",");
|
|
93
|
m_writer.Write(",");
|
|
94
|
WriteIndent();
|
|
94
|
WriteIndent();
|
|
95
|
m_context.needComma = true;
|
|
95
|
m_context.needComma = true;
|
|
96
|
|
|
96
|
|
|
97
|
Write(value);
|
|
97
|
Write(value);
|
|
|
|
|
98
|
} else if (m_context.element == JSONElementContext.None) {
|
|
|
|
|
99
|
Write(value);
|
|
|
|
|
100
|
m_context.element = JSONElementContext.Closed;
|
|
|
|
|
101
|
} else {
|
|
|
|
|
102
|
OperationNotApplicable("WriteValue");
|
|
|
|
|
103
|
}
|
|
98
|
}
|
|
104
|
}
|
|
99
|
|
|
105
|
|
|
100
|
public void WriteValue(bool value) {
|
|
106
|
public void WriteValue(bool value) {
|
|
101
|
if (m_context.element != JSONElementContext.Array)
|
|
107
|
if (m_context.element == JSONElementContext.Array) {
|
|
102
|
OperationNotApplicable("WriteValue");
|
|
108
|
|
|
103
|
if (m_context.needComma)
|
|
109
|
if (m_context.needComma)
|
|
104
|
m_writer.Write(",");
|
|
110
|
m_writer.Write(",");
|
|
|
|
|
111
|
WriteIndent();
|
|
105
|
m_context.needComma = true;
|
|
112
|
m_context.needComma = true;
|
|
106
|
|
|
113
|
|
|
107
|
WriteIndent();
|
|
114
|
Write(value);
|
|
|
|
|
115
|
} else if (m_context.element == JSONElementContext.None) {
|
|
108
|
Write(value);
|
|
116
|
Write(value);
|
|
|
|
|
117
|
m_context.element = JSONElementContext.Closed;
|
|
|
|
|
118
|
} else {
|
|
|
|
|
119
|
OperationNotApplicable("WriteValue");
|
|
|
|
|
120
|
}
|
|
109
|
}
|
|
121
|
}
|
|
110
|
|
|
122
|
|
|
111
|
public void WriteValue(double value) {
|
|
123
|
public void WriteValue(double value) {
|
|
112
|
if (m_context.element != JSONElementContext.Array)
|
|
124
|
if (m_context.element == JSONElementContext.Array) {
|
|
113
|
OperationNotApplicable("WriteValue");
|
|
125
|
|
|
114
|
if (m_context.needComma)
|
|
126
|
if (m_context.needComma)
|
|
115
|
m_writer.Write(",");
|
|
127
|
m_writer.Write(",");
|
|
|
|
|
128
|
WriteIndent();
|
|
116
|
m_context.needComma = true;
|
|
129
|
m_context.needComma = true;
|
|
117
|
|
|
130
|
|
|
118
|
WriteIndent();
|
|
131
|
Write(value);
|
|
|
|
|
132
|
} else if (m_context.element == JSONElementContext.None) {
|
|
119
|
Write(value);
|
|
133
|
Write(value);
|
|
|
|
|
134
|
m_context.element = JSONElementContext.Closed;
|
|
|
|
|
135
|
} else {
|
|
|
|
|
136
|
OperationNotApplicable("WriteValue");
|
|
|
|
|
137
|
}
|
|
120
|
}
|
|
138
|
}
|
|
121
|
|
|
139
|
|
|
122
|
public void BeginObject() {
|
|
140
|
public void BeginObject() {
|
|
@@
-146,9
+164,11
namespace Implab.JSON {
|
|
146
|
|
|
164
|
|
|
147
|
public void EndObject() {
|
|
165
|
public void EndObject() {
|
|
148
|
if (m_context.element != JSONElementContext.Object)
|
|
166
|
if (m_context.element != JSONElementContext.Object)
|
|
149
|
OperationNotApplicable("EndArray");
|
|
167
|
OperationNotApplicable("EndObject");
|
|
150
|
|
|
168
|
|
|
151
|
m_context = m_contextStack.Pop();
|
|
169
|
m_context = m_contextStack.Pop();
|
|
|
|
|
170
|
if (m_contextStack.Count == 0)
|
|
|
|
|
171
|
m_context.element = JSONElementContext.Closed;
|
|
152
|
WriteIndent();
|
|
172
|
WriteIndent();
|
|
153
|
m_writer.Write("}");
|
|
173
|
m_writer.Write("}");
|
|
154
|
}
|
|
174
|
}
|
|
@@
-182,6
+202,8
namespace Implab.JSON {
|
|
182
|
OperationNotApplicable("EndArray");
|
|
202
|
OperationNotApplicable("EndArray");
|
|
183
|
|
|
203
|
|
|
184
|
m_context = m_contextStack.Pop();
|
|
204
|
m_context = m_contextStack.Pop();
|
|
|
|
|
205
|
if (m_contextStack.Count == 0)
|
|
|
|
|
206
|
m_context.element = JSONElementContext.Closed;
|
|
185
|
WriteIndent();
|
|
207
|
WriteIndent();
|
|
186
|
m_writer.Write("]");
|
|
208
|
m_writer.Write("]");
|
|
187
|
}
|
|
209
|
}
|