Skip to content

Commit

Permalink
bug fixed for issue 1005.
Browse files Browse the repository at this point in the history
  • Loading branch information
wuwen5 committed Jan 19, 2017
1 parent fbba126 commit 0292219
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Expand Up @@ -174,7 +174,7 @@ public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
componentType = componentClass = clazz.getComponentType();
}
JSONArray array = new JSONArray();
parser.parseArray(componentClass, array, fieldName);
parser.parseArray(componentType, array, fieldName);

return (T) toObjectArray(parser, componentClass, array);
}
Expand Down
17 changes: 16 additions & 1 deletion src/test/java/com/alibaba/json/bvt/bug/Issue1005.java
Expand Up @@ -10,7 +10,18 @@
*/
public class Issue1005 extends TestCase {
public void test_for_issue() throws Exception {
Model model = JSON.parseObject("{\"values\":[1,2,3]}", Model.class);
Model model = JSON.parseObject("{\"values\":[[1,2,3]]}", Model.class);

assertNotNull(model.values);
assertEquals(3, model.values[0].size());
assertEquals(Byte.class, model.values[0].get(0).getClass());
assertEquals(Byte.class, model.values[0].get(1).getClass());
assertEquals(Byte.class, model.values[0].get(2).getClass());
}

public void test_for_List() throws Exception {
Model2 model = JSON.parseObject("{\"values\":[1,2,3]}", Model2.class);

assertNotNull(model.values);
assertEquals(3, model.values.size());
assertEquals(Byte.class, model.values.get(0).getClass());
Expand All @@ -19,6 +30,10 @@ public void test_for_issue() throws Exception {
}

public static class Model {
public List<Byte>[] values;
}

public static class Model2 {
public List<Byte> values;
}
}

0 comments on commit 0292219

Please sign in to comment.