Mercurial Hosting > luan
annotate core/src/luan/modules/parsers/Json.java @ 758:c29d11d675fd
added Json.toString() and rpc now sends tables as json
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 19 Jul 2016 00:57:37 -0600 |
parents | bdd766df1c17 |
children | ae612dfc57cb |
rev | line source |
---|---|
720 | 1 package luan.modules.parsers; |
2 | |
3 import java.util.List; | |
4 import java.util.ArrayList; | |
5 import java.util.Map; | |
6 import java.util.LinkedHashMap; | |
758
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
7 import java.util.Iterator; |
720 | 8 import luan.LuanTable; |
758
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
9 import luan.LuanException; |
720 | 10 |
11 | |
12 public final class Json { | |
13 | |
14 public static Object parse(String text) throws ParseException { | |
15 return new Json(text).parse(); | |
16 } | |
17 | |
18 private final Parser parser; | |
19 | |
20 private Json(String text) { | |
21 this.parser = new Parser(text); | |
22 } | |
23 | |
24 private ParseException exception(String msg) { | |
25 return new ParseException(parser,msg); | |
26 } | |
27 | |
28 private Object parse() throws ParseException { | |
29 spaces(); | |
30 Object value = value(); | |
31 spaces(); | |
32 if( !parser.endOfInput() ) | |
33 throw exception("unexpected text"); | |
34 return value; | |
35 } | |
36 | |
37 private Object value() throws ParseException { | |
38 if( parser.match("null") ) | |
39 return null; | |
40 if( parser.match("true") ) | |
41 return Boolean.TRUE; | |
42 if( parser.match("false") ) | |
43 return Boolean.FALSE; | |
44 String s = string(); | |
45 if( s != null ) | |
46 return s; | |
47 Number n = number(); | |
48 if( n != null ) | |
49 return n; | |
50 LuanTable a = array(); | |
51 if( a != null ) | |
52 return a; | |
53 LuanTable o = object(); | |
54 if( o != null ) | |
55 return o; | |
56 throw exception("invalid value"); | |
57 } | |
58 | |
59 private String string() throws ParseException { | |
60 parser.begin(); | |
61 if( !parser.match('"') ) | |
62 return parser.failure(null); | |
63 StringBuilder sb = new StringBuilder(); | |
64 while( parser.anyChar() ) { | |
65 char c = parser.lastChar(); | |
66 switch(c) { | |
67 case '"': | |
68 return parser.success(sb.toString()); | |
69 case '\\': | |
70 if( parser.anyChar() ) { | |
71 c = parser.lastChar(); | |
72 switch(c) { | |
73 case '"': | |
74 case '\\': | |
75 case '/': | |
76 sb.append(c); | |
77 continue; | |
78 case 'b': | |
79 sb.append('\b'); | |
80 continue; | |
81 case 'f': | |
82 sb.append('\f'); | |
83 continue; | |
84 case 'n': | |
85 sb.append('\n'); | |
86 continue; | |
87 case 'r': | |
88 sb.append('\r'); | |
89 continue; | |
90 case 't': | |
91 sb.append('\t'); | |
92 continue; | |
93 case 'u': | |
94 int n = 0; | |
95 for( int i=0; i<4; i++ ) { | |
96 int d; | |
97 if( parser.inCharRange('0','9') ) { | |
98 d = parser.lastChar() - '0'; | |
99 } else if( parser.inCharRange('a','f') ) { | |
100 d = parser.lastChar() - 'a' + 10; | |
101 } else if( parser.inCharRange('A','F') ) { | |
102 d = parser.lastChar() - 'A' + 10; | |
103 } else { | |
104 throw exception("invalid hex digit"); | |
105 } | |
106 n = 16*n + d; | |
107 } | |
108 sb.append((char)n); | |
109 continue; | |
110 } | |
111 } | |
112 throw exception("invalid escape char"); | |
113 default: | |
114 sb.append(c); | |
115 } | |
116 } | |
117 parser.failure(); | |
118 throw exception("unclosed string"); | |
119 } | |
120 | |
121 private Number number() { | |
122 int start = parser.begin(); | |
123 parser.match('-'); | |
124 if( !parser.match('0') ) { | |
125 if( !parser.inCharRange('1','9') ) | |
126 return parser.failure(null); | |
127 while( parser.inCharRange('0','9') ); | |
128 } | |
129 if( parser.match('.') ) { | |
130 if( !parser.inCharRange('0','9') ) | |
131 return parser.failure(null); | |
132 while( parser.inCharRange('0','9') ); | |
133 } | |
134 if( parser.anyOf("eE") ) { | |
135 parser.anyOf("+-"); | |
136 if( !parser.inCharRange('0','9') ) | |
137 return parser.failure(null); | |
138 while( parser.inCharRange('0','9') ); | |
139 } | |
140 String s = parser.textFrom(start); | |
141 return parser.success(Double.valueOf(s)); | |
142 } | |
143 | |
144 private LuanTable array() throws ParseException { | |
145 parser.begin(); | |
146 if( !parser.match('[') ) | |
147 return parser.failure(null); | |
148 spaces(); | |
149 if( parser.match(']') ) | |
150 return parser.success(new LuanTable()); | |
151 List list = new ArrayList(); | |
152 list.add( value() ); | |
153 spaces(); | |
154 while( parser.match(',') ) { | |
155 spaces(); | |
156 list.add( value() ); | |
157 spaces(); | |
158 } | |
159 if( parser.match(']') ) | |
160 return parser.success(new LuanTable(list)); | |
161 if( parser.endOfInput() ) { | |
162 parser.failure(); | |
163 throw exception("unclosed array"); | |
164 } | |
165 throw exception("unexpected text in array"); | |
166 } | |
167 | |
168 private LuanTable object() throws ParseException { | |
169 parser.begin(); | |
170 if( !parser.match('{') ) | |
171 return parser.failure(null); | |
172 spaces(); | |
173 if( parser.match('}') ) | |
174 return parser.success(new LuanTable()); | |
175 Map map = new LinkedHashMap(); | |
176 addEntry(map); | |
177 while( parser.match(',') ) { | |
178 spaces(); | |
179 addEntry(map); | |
180 } | |
181 if( parser.match('}') ) | |
182 return parser.success(new LuanTable(map)); | |
183 if( parser.endOfInput() ) { | |
184 parser.failure(); | |
185 throw exception("unclosed object"); | |
186 } | |
187 throw exception("unexpected text in object"); | |
188 } | |
189 | |
190 private void addEntry(Map map) throws ParseException { | |
191 String key = string(); | |
192 if( key==null ) | |
193 throw exception("invalid object key"); | |
194 spaces(); | |
195 if( !parser.match(':') ) | |
196 throw exception("':' expected"); | |
197 spaces(); | |
198 Object value = value(); | |
199 spaces(); | |
200 map.put(key,value); | |
201 } | |
202 | |
203 private void spaces() { | |
204 while( parser.anyOf(" \t\r\n") ); | |
205 } | |
758
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
206 |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
207 |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
208 |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
209 |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
210 |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
211 |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
212 |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
213 |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
214 |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
215 public static String toString(Object obj) throws LuanException { |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
216 StringBuilder sb = new StringBuilder(); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
217 toString(obj,sb); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
218 return sb.toString(); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
219 } |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
220 |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
221 private static void toString(Object obj,StringBuilder sb) throws LuanException { |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
222 if( obj == null || obj instanceof Boolean || obj instanceof Number ) { |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
223 sb.append(obj); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
224 return; |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
225 } |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
226 if( obj instanceof String ) { |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
227 toString((String)obj,sb); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
228 return; |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
229 } |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
230 if( obj instanceof LuanTable ) { |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
231 toString((LuanTable)obj,sb); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
232 return; |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
233 } |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
234 throw new LuanException("can't handle type "+obj.getClass().getName()); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
235 } |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
236 |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
237 private static void toString(final String s,StringBuilder sb) { |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
238 sb.append('"'); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
239 for( int i=0; i<s.length(); i++ ) { |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
240 char c = s.charAt(i); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
241 switch(c) { |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
242 case '"': |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
243 sb.append("\\\""); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
244 break; |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
245 case '\\': |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
246 sb.append("\\\\"); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
247 break; |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
248 case '\b': |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
249 sb.append("\\b"); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
250 break; |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
251 case '\f': |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
252 sb.append("\\f"); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
253 break; |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
254 case '\n': |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
255 sb.append("\\n"); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
256 break; |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
257 case '\r': |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
258 sb.append("\\r"); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
259 break; |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
260 case '\t': |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
261 sb.append("\\t"); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
262 break; |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
263 default: |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
264 sb.append(c); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
265 } |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
266 } |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
267 sb.append('"'); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
268 } |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
269 |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
270 private static void toString(LuanTable t,StringBuilder sb) throws LuanException { |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
271 if( t.isList() ) { |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
272 final List list = t.asList(); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
273 if( list.isEmpty() ) { |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
274 sb.append("{}"); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
275 return; |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
276 } |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
277 sb.append('['); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
278 toString(list.get(0),sb); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
279 for( int i=1; i<list.size(); i++ ) { |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
280 sb.append(','); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
281 toString(list.get(i),sb); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
282 } |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
283 sb.append(']'); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
284 return; |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
285 } |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
286 sb.append('{'); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
287 Iterator<Map.Entry<Object,Object>> i = t.rawIterator(); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
288 toString(i.next(),sb); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
289 while( i.hasNext() ) { |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
290 sb.append(','); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
291 toString(i.next(),sb); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
292 } |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
293 sb.append('}'); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
294 } |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
295 |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
296 private static void toString(Map.Entry<Object,Object> entry,StringBuilder sb) throws LuanException { |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
297 Object key = entry.getKey(); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
298 if( !(key instanceof String) ) |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
299 throw new LuanException("table keys must be strings"); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
300 toString((String)key,sb); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
301 sb.append(':'); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
302 toString(entry.getValue(),sb); |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
303 } |
c29d11d675fd
added Json.toString() and rpc now sends tables as json
Franklin Schmidt <fschmidt@gmail.com>
parents:
720
diff
changeset
|
304 |
720 | 305 } |