Mercurial Hosting > luan
diff 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 |
line wrap: on
line diff
--- a/src/luan/modules/BasicLuan.java Fri Oct 18 22:29:46 2019 -0600 +++ b/src/luan/modules/BasicLuan.java Fri Oct 25 22:12:06 2019 -0600 @@ -8,6 +8,7 @@ import java.util.List; import java.util.ArrayList; import java.util.Arrays; +import goodjava.json.JsonToString; import luan.Luan; import luan.LuanTable; import luan.LuanFunction; @@ -265,10 +266,25 @@ Boolean numberTypes = Utils.removeBoolean(map,"number_types"); if( numberTypes != null ) lts.numberTypes = numberTypes; + Boolean compressed = Utils.removeBoolean(map,"compressed"); + if( compressed != null ) + lts.compressed = compressed; Utils.checkEmpty(map); } return lts.toString(obj); } + public static String json_string(Object obj,LuanTable options) throws LuanException { + JsonToString jts = new JsonToString(); + if( options != null ) { + Map map = options.asMap(); + Boolean compressed = Utils.removeBoolean(map,"compressed"); + if( compressed != null ) + jts.compressed = compressed; + Utils.checkEmpty(map); + } + return jts.toString(Luan.toJava(obj)); + } + private void BasicLuan() {} // never }