changeset 1805:7793bcb5f34a

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 08 May 2024 11:13:16 -0600
parents b4328322d2be
children 3b7a8f1cc887
files src/luan/Luan.java src/luan/modules/BasicLuan.java src/luan/modules/Parsers.luan
diffstat 3 files changed, 7 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/luan/Luan.java	Tue May 07 22:08:37 2024 -0600
+++ b/src/luan/Luan.java	Wed May 08 11:13:16 2024 -0600
@@ -423,11 +423,9 @@
 		return load(text,sourceName,persist,null);
 	}
 
+	public static final Object nullValue = new Object();
+
 	public static Object toJava(Object obj) throws LuanException {
-		return toJava(obj,null);
-	}
-
-	public static Object toJava(Object obj,Object nullValue) throws LuanException {
 		if( obj == nullValue )
 			return null;
 		if( !(obj instanceof LuanTable) )
@@ -436,7 +434,7 @@
 		if( !tbl.isMap() ) {
 			List list = new ArrayList();
 			for( Object el : tbl.asList() ) {
-				list.add( toJava(el,nullValue) );
+				list.add( toJava(el) );
 			}
 			return list;
 		} else {
@@ -444,7 +442,7 @@
 			Iterator<Map.Entry> iter = tbl.rawIterator();
 			while( iter.hasNext() ) {
 				Map.Entry entry = iter.next();
-				map.put( toJava(entry.getKey(),nullValue), toJava(entry.getValue(),nullValue) );
+				map.put( toJava(entry.getKey()), toJava(entry.getValue()) );
 			}
 			return map;
 		}
--- a/src/luan/modules/BasicLuan.java	Tue May 07 22:08:37 2024 -0600
+++ b/src/luan/modules/BasicLuan.java	Wed May 08 11:13:16 2024 -0600
@@ -227,8 +227,6 @@
 		throw new LuanException("options must be table of function");
 	}
 
-	public static final Object json_null = new Object();
-
 	public static String json_string(Object obj,LuanTable options) throws LuanException {
 		JsonToString jts = new JsonToString();
 		if( options != null ) {
@@ -238,7 +236,7 @@
 				jts.compressed = compressed;
 			Utils.checkEmpty(options);
 		}
-		return jts.toString(Luan.toJava(obj,json_null));
+		return jts.toString(Luan.toJava(obj));
 	}
 
 	public static Object get_local_cloned(Luan luan,Object obj,Object key) {
--- a/src/luan/modules/Parsers.luan	Tue May 07 22:08:37 2024 -0600
+++ b/src/luan/modules/Parsers.luan	Wed May 08 11:13:16 2024 -0600
@@ -7,6 +7,7 @@
 local Xml2 = require "java:luan.modules.parsers.Xml2"
 local XmlElement = require "java:goodjava.xml.XmlElement"
 local BasicLuan = require "java:luan.modules.BasicLuan"
+local LuanJava = require "java:luan.Luan"
 
 
 local Parsers = {}
@@ -14,7 +15,7 @@
 Parsers.bbcode_encode = BBCode.encode
 Parsers.bbcode_parse = BBCodeLuan.parse
 Parsers.csv_to_list = Csv.toList
-Parsers.json_null = BasicLuan.json_null
+Parsers.json_null = LuanJava.nullValue
 Parsers.json_string = BasicLuan.json_string
 Parsers.theme_to_luan = Theme.toLuan
 Parsers.xml_encode = XmlElement.encode