mirror of
https://github.com/alibaba/fastjson.git
synced 2026-10-29 14:10:25 +08:00
add testcase
This commit is contained in:
@@ -7,7 +7,6 @@ import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -59,12 +58,7 @@ public class JavaBeanDeserializer implements ObjectDeserializer {
|
||||
if (clazz.isInterface()) {
|
||||
Class<?> clazz = (Class<?>) type;
|
||||
ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
||||
JSONObject object;
|
||||
if ((parser.lexer.features & Feature.OrderedField.mask) != 0) {
|
||||
object = new JSONObject(new LinkedHashMap<String, Object>());
|
||||
} else {
|
||||
object = new JSONObject();
|
||||
}
|
||||
JSONObject object = new JSONObject();
|
||||
Object proxy = Proxy.newProxyInstance(loader, new Class<?>[] { clazz }, object);
|
||||
return proxy;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.alibaba.json.bvt.parser;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.parser.Feature;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class OrderedFieldTest extends TestCase {
|
||||
public void test_ordered_field() throws Exception {
|
||||
Model model = JSON.parseObject("{\"id\":1001}", Model.class, Feature.OrderedField);
|
||||
Assert.assertEquals(1001, model.getId());
|
||||
|
||||
}
|
||||
|
||||
public static interface Model {
|
||||
public int getId();
|
||||
public void setId(int value);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user