support alias annotation

This commit is contained in:
Looly
2020-02-28 23:50:28 +08:00
parent 63e761139b
commit 623d5ef5c9
9 changed files with 87 additions and 26 deletions

View File

@@ -55,13 +55,13 @@ final class InternalJSONUtil {
} else if (value instanceof Boolean) {
writer.write(value.toString());
} else if (value instanceof JSONString) {
Object o;
String valueStr;
try {
o = ((JSONString) value).toJSONString();
valueStr = ((JSONString) value).toJSONString();
} catch (Exception e) {
throw new JSONException(e);
}
writer.write(o != null ? o.toString() : JSONUtil.quote(value.toString()));
writer.write(valueStr != null ? valueStr : JSONUtil.quote(value.toString()));
} else {
JSONUtil.quote(value.toString(), writer);
}

View File

@@ -19,7 +19,7 @@ public class CustomSerializeTest {
JSONObject obj = JSONUtil.parseObj(customBean);
Assert.assertEquals("testName", obj.getStr("customName"));
}
@Test
public void deserializeTest() {
JSONUtil.putDeserializer(CustomBean.class, json -> {