and some culling

This commit is contained in:
benfry
2012-12-11 01:12:16 +00:00
parent d33c152ee1
commit 2e9b3cd747
2 changed files with 15 additions and 32 deletions

View File

@@ -1444,18 +1444,18 @@ public class JSONObject {
if (value == null || value.equals(null)) {
return "null";
}
if (value instanceof JSONString) {
Object object;
try {
object = ((JSONString)value).toJSONString();
} catch (Exception e) {
throw new RuntimeException(e);
}
if (object instanceof String) {
return (String)object;
}
throw new RuntimeException("Bad value from toJSONString: " + object);
}
// if (value instanceof JSONString) {
// Object object;
// try {
// object = ((JSONString)value).toJSONString();
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// if (object instanceof String) {
// return (String)object;
// }
// throw new RuntimeException("Bad value from toJSONString: " + object);
// }
if (value instanceof Number) {
return numberToString((Number) value);
}
@@ -1493,7 +1493,7 @@ public class JSONObject {
return NULL;
}
if (object instanceof JSONObject || object instanceof JSONArray ||
NULL.equals(object) || object instanceof JSONString ||
NULL.equals(object) || /*object instanceof JSONString ||*/
object instanceof Byte || object instanceof Character ||
object instanceof Short || object instanceof Integer ||
object instanceof Long || object instanceof Boolean ||
@@ -1562,6 +1562,7 @@ public class JSONObject {
writer.write(numberToString((Number) value));
} else if (value instanceof Boolean) {
writer.write(value.toString());
/*
} else if (value instanceof JSONString) {
Object o;
try {
@@ -1570,6 +1571,7 @@ public class JSONObject {
throw new RuntimeException(e);
}
writer.write(o != null ? o.toString() : quote(value.toString()));
*/
} else {
quote(value.toString(), writer);
}

View File

@@ -1,19 +0,0 @@
package processing.data;
/**
* The <code>JSONString</code> interface allows a <code>toJSONString()</code>
* method so that a class can change the behavior of
* <code>JSONObject.toString()</code>, <code>JSONArray.toString()</code>,
* and <code>JSONWriter.value(</code>Object<code>)</code>. The
* <code>toJSONString</code> method will be used instead of the default behavior
* of using the Object's <code>toString()</code> method and quoting the result.
*/
public interface JSONString {
/**
* The <code>toJSONString</code> method allows a class to produce its own JSON
* serialization.
*
* @return A strictly syntactically correct JSON text.
*/
public String toJSONString();
}