Mercurial Hosting > luan
comparison src/luan/modules/BasicLuan.java @ 1419:59fd2e8b1b9d
stringify and json_string
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 25 Oct 2019 22:12:06 -0600 |
parents | eb8b35dccd99 |
children | 225808b90cee |
comparison
equal
deleted
inserted
replaced
1418:732b5de211fc | 1419:59fd2e8b1b9d |
---|---|
6 import java.util.Iterator; | 6 import java.util.Iterator; |
7 import java.util.Map; | 7 import java.util.Map; |
8 import java.util.List; | 8 import java.util.List; |
9 import java.util.ArrayList; | 9 import java.util.ArrayList; |
10 import java.util.Arrays; | 10 import java.util.Arrays; |
11 import goodjava.json.JsonToString; | |
11 import luan.Luan; | 12 import luan.Luan; |
12 import luan.LuanTable; | 13 import luan.LuanTable; |
13 import luan.LuanFunction; | 14 import luan.LuanFunction; |
14 import luan.LuanException; | 15 import luan.LuanException; |
15 import luan.LuanCloner; | 16 import luan.LuanCloner; |
263 if( strict != null ) | 264 if( strict != null ) |
264 lts.strict = strict; | 265 lts.strict = strict; |
265 Boolean numberTypes = Utils.removeBoolean(map,"number_types"); | 266 Boolean numberTypes = Utils.removeBoolean(map,"number_types"); |
266 if( numberTypes != null ) | 267 if( numberTypes != null ) |
267 lts.numberTypes = numberTypes; | 268 lts.numberTypes = numberTypes; |
269 Boolean compressed = Utils.removeBoolean(map,"compressed"); | |
270 if( compressed != null ) | |
271 lts.compressed = compressed; | |
268 Utils.checkEmpty(map); | 272 Utils.checkEmpty(map); |
269 } | 273 } |
270 return lts.toString(obj); | 274 return lts.toString(obj); |
275 } | |
276 | |
277 public static String json_string(Object obj,LuanTable options) throws LuanException { | |
278 JsonToString jts = new JsonToString(); | |
279 if( options != null ) { | |
280 Map map = options.asMap(); | |
281 Boolean compressed = Utils.removeBoolean(map,"compressed"); | |
282 if( compressed != null ) | |
283 jts.compressed = compressed; | |
284 Utils.checkEmpty(map); | |
285 } | |
286 return jts.toString(Luan.toJava(obj)); | |
271 } | 287 } |
272 | 288 |
273 private void BasicLuan() {} // never | 289 private void BasicLuan() {} // never |
274 } | 290 } |