comparison src/luan/modules/BasicLuan.java @ 1420:225808b90cee

options handling
author Franklin Schmidt <fschmidt@gmail.com>
date Sat, 26 Oct 2019 22:21:09 -0600
parents 59fd2e8b1b9d
children 9ab267b9427c
comparison
equal deleted inserted replaced
1419:59fd2e8b1b9d 1420:225808b90cee
257 } 257 }
258 258
259 public static String stringify(Object obj,LuanTable options) throws LuanException { 259 public static String stringify(Object obj,LuanTable options) throws LuanException {
260 LuanToString lts = new LuanToString(); 260 LuanToString lts = new LuanToString();
261 if( options != null ) { 261 if( options != null ) {
262 Map map = options.asMap(); 262 options = new LuanTable(options);
263 Boolean strict = Utils.removeBoolean(map,"strict"); 263 Boolean strict = Utils.removeBoolean(options,"strict");
264 if( strict != null ) 264 if( strict != null )
265 lts.strict = strict; 265 lts.strict = strict;
266 Boolean numberTypes = Utils.removeBoolean(map,"number_types"); 266 Boolean numberTypes = Utils.removeBoolean(options,"number_types");
267 if( numberTypes != null ) 267 if( numberTypes != null )
268 lts.numberTypes = numberTypes; 268 lts.numberTypes = numberTypes;
269 Boolean compressed = Utils.removeBoolean(map,"compressed"); 269 Boolean compressed = Utils.removeBoolean(options,"compressed");
270 if( compressed != null ) 270 if( compressed != null )
271 lts.compressed = compressed; 271 lts.compressed = compressed;
272 Utils.checkEmpty(map); 272 Utils.checkEmpty(options);
273 } 273 }
274 return lts.toString(obj); 274 return lts.toString(obj);
275 } 275 }
276 276
277 public static String json_string(Object obj,LuanTable options) throws LuanException { 277 public static String json_string(Object obj,LuanTable options) throws LuanException {
278 JsonToString jts = new JsonToString(); 278 JsonToString jts = new JsonToString();
279 if( options != null ) { 279 if( options != null ) {
280 Map map = options.asMap(); 280 options = new LuanTable(options);
281 Boolean compressed = Utils.removeBoolean(map,"compressed"); 281 Boolean compressed = Utils.removeBoolean(options,"compressed");
282 if( compressed != null ) 282 if( compressed != null )
283 jts.compressed = compressed; 283 jts.compressed = compressed;
284 Utils.checkEmpty(map); 284 Utils.checkEmpty(options);
285 } 285 }
286 return jts.toString(Luan.toJava(obj)); 286 return jts.toString(Luan.toJava(obj));
287 } 287 }
288 288
289 private void BasicLuan() {} // never 289 private void BasicLuan() {} // never