fixes for IBM jvm
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1227 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
9a02a4e57a
commit
4db0b78667
|
@ -271,11 +271,14 @@ public class JSON
|
|||
appendNumber(buffer,(Number)object);
|
||||
else if (object instanceof Boolean)
|
||||
appendBoolean(buffer,(Boolean)object);
|
||||
else if (object instanceof Character)
|
||||
appendString(buffer,object.toString());
|
||||
else if (object instanceof String)
|
||||
appendString(buffer,(String)object);
|
||||
else
|
||||
{
|
||||
Convertor convertor=getConvertor(object.getClass());
|
||||
System.err.println("Convertor for '"+object+"' is "+convertor);
|
||||
if (convertor!=null)
|
||||
appendJSON(buffer,convertor,object);
|
||||
else
|
||||
|
|
|
@ -26,9 +26,10 @@ public class JSONPojoConvertorFactoryTest extends TestCase {
|
|||
JSON jsonOut = new JSON();
|
||||
JSON jsonIn = new JSON();
|
||||
|
||||
JSON.registerConvertor(Object.class, new JSONPojoConvertorFactory(jsonOut));
|
||||
JSON.registerConvertor(Object.class, new JSONPojoConvertorFactory(jsonIn));
|
||||
JSON.registerConvertor(Enum.class, new JSONEnumConvertor());
|
||||
jsonOut.addConvertor(Object.class, new JSONPojoConvertorFactory(jsonOut));
|
||||
jsonOut.addConvertor(Enum.class, new JSONEnumConvertor());
|
||||
jsonIn.addConvertor(Object.class, new JSONPojoConvertorFactory(jsonIn));
|
||||
jsonIn.addConvertor(Enum.class, new JSONEnumConvertor());
|
||||
|
||||
Foo foo = new Foo();
|
||||
foo._name = "Foo @ " + System.currentTimeMillis();
|
||||
|
|
|
@ -73,7 +73,10 @@ public class JSONTest extends TestCase
|
|||
map.put("w0",w0);
|
||||
|
||||
obj7.put("x","value");
|
||||
|
||||
|
||||
System.err.println();
|
||||
System.err.println();
|
||||
|
||||
String s = JSON.toString(map);
|
||||
assertTrue(s.indexOf("\"n1\":null")>=0);
|
||||
assertTrue(s.indexOf("\"n2\":2")>=0);
|
||||
|
@ -85,7 +88,7 @@ public class JSONTest extends TestCase
|
|||
assertTrue(s.indexOf("\"n8\":[1,2,3,4]")>=0);
|
||||
assertTrue(s.indexOf("\"n9\":[{}, [], {}]")>=0);
|
||||
assertTrue(s.indexOf("\"w0\":{\"class\":\"org.eclipse.jetty.util.ajax.JSONTest$Woggle\",\"name\":\"woggle0\",\"nested\":{\"class\":\"org.eclipse.jetty.util.ajax.JSONTest$Woggle\",\"name\":\"woggle1\",\"nested\":null,\"number\":-101},\"number\":100}")>=0);
|
||||
|
||||
|
||||
Gadget gadget = new Gadget();
|
||||
gadget.setShields(42);
|
||||
gadget.setWoggles(new Woggle[]{w0,w1});
|
||||
|
@ -271,7 +274,6 @@ public class JSONTest extends TestCase
|
|||
json.append(buf,map);
|
||||
String js=buf.toString();
|
||||
|
||||
System.err.println(js);
|
||||
assertTrue(js.indexOf("\"date\":\"01/01/1970 00:00:00 GMT\"")>=0);
|
||||
assertTrue(js.indexOf("org.eclipse.jetty.util.ajax.JSONTest$Woggle")>=0);
|
||||
assertTrue(js.indexOf("org.eclipse.jetty.util.ajax.JSONTest$Gizmo")<0);
|
||||
|
@ -302,7 +304,6 @@ public class JSONTest extends TestCase
|
|||
buf = new StringBuffer();
|
||||
json.append(buf,map);
|
||||
js=buf.toString();
|
||||
System.err.println(js);
|
||||
assertTrue(js.indexOf("\"date\":\"Thu Jan 01 00:00:00 GMT 1970\"")<0);
|
||||
assertTrue(js.indexOf("org.eclipse.jetty.util.ajax.JSONTest$Woggle")>=0);
|
||||
assertTrue(js.indexOf("org.eclipse.jetty.util.ajax.JSONTest$Gizmo")<0);
|
||||
|
|
Loading…
Reference in New Issue