• R/O
  • SSH
  • HTTPS

jsonic: コミット


コミットメタ情報

リビジョン1848 (tree)
日時2014-12-14 02:52:01
作者hizuno

ログメッセージ

(メッセージはありません)

変更サマリ

差分

--- trunk/jsonic-1.3/src/net/arnx/jsonic/JSON.java (revision 1847)
+++ trunk/jsonic-1.3/src/net/arnx/jsonic/JSON.java (revision 1848)
@@ -943,7 +943,7 @@
943943 try {
944944 int len;
945945 if (source == null) {
946- len = 4;
946+ return "null";
947947 } else if (source instanceof CharSequence) {
948948 len = ((CharSequence)source).length() + 16;
949949 } else if (source instanceof Boolean) {
@@ -1202,6 +1202,8 @@
12021202 c = SerializableConverter.INSTANCE;
12031203 } else if (String.class.equals(hint.type())) {
12041204 c = StringSerializableConverter.INSTANCE;
1205+ } else if (hint.type() != Object.class && cls.isAssignableFrom(hint.type())) {
1206+ cls = hint.type().asSubclass(cls);
12051207 }
12061208 }
12071209
@@ -1262,9 +1264,6 @@
12621264 protected <T> T create(Context context, Class<? extends T> c) throws Exception {
12631265 Object instance = null;
12641266
1265- JSONHint hint = context.getHint();
1266- if (hint != null && hint.type() != Object.class) c = hint.type().asSubclass(c);
1267-
12681267 if (Collection.class.equals(c) || List.class.equals(c) || ArrayList.class.equals(c)) {
12691268 if (context.createSizeHint >= 0) {
12701269 instance = new ArrayList<Object>(context.createSizeHint);
--- trunk/jsonic-1.3/test/net/arnx/jsonic/JSONBugTest.java (revision 1847)
+++ trunk/jsonic-1.3/test/net/arnx/jsonic/JSONBugTest.java (revision 1848)
@@ -29,9 +29,8 @@
2929 public void testSuperClass() {
3030 TestClass test = new TestClass();
3131 assertEquals("{\"test\":{\"hoge\":\"hoge\"}}", JSON.encode(test));
32-
33- System.out.println(JSON.decode("{\"test\":{\"hoge\":\"hoge\"}}", TestClass.class).test.getClass());
34- assertEquals(test, JSON.decode("{\"test\":{\"hoge\":\"hoge\"}}", TestClass.class));
32+ ((SubClass)test.test).hoge = "bar";
33+ assertEquals(test, JSON.decode("{\"test\":{\"hoge\":\"bar\"}}", TestClass.class));
3534 }
3635
3736 public static class TestClass {
@@ -62,6 +61,11 @@
6261 return false;
6362 return true;
6463 }
64+
65+ @Override
66+ public String toString() {
67+ return "TestClass [test=" + test + "]";
68+ }
6569 }
6670
6771 public static class SuperClass {
@@ -115,5 +119,10 @@
115119 return false;
116120 return true;
117121 }
122+
123+ @Override
124+ public String toString() {
125+ return "SubClass [hoge=" + hoge + "]";
126+ }
118127 }
119128 }
旧リポジトリブラウザで表示