JSONDeserializer error on empty array
Brought to you by:
charliehubbard
test value : {"myList" : []}
Exception
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at flexjson.ObjectBinder.bind(ObjectBinder.java:77)
at flexjson.ObjectBinder.bindIntoMap(ObjectBinder.java:116)
at flexjson.factories.MapObjectFactory.instantiate(MapObjectFactory.java:19)
...
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
I receive the same error with an empty array: {"devices":[]}
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at flexjson.ObjectBinder.bind(ObjectBinder.java:73)
at flexjson.ObjectBinder.bindIntoMap(ObjectBinder.java:112)
at flexjson.factories.MapObjectFactory.instantiate(MapObjectFactory.java:17)
at flexjson.ObjectBinder.bind(ObjectBinder.java:68)
at flexjson.ObjectBinder.bind(ObjectBinder.java:60)
at flexjson.JSONDeserializer.deserialize(JSONDeserializer.java:156)
...
Last edit: Anonymous 2015-12-17
This appears to be fixed in 2.0 so I'm marking it fixed according to this unit test:
public void testEmptyArray() {
Group group = new JSONDeserializer<Group>().deserialize("{'people': [], 'groupName': 'Nobody' }", Group.class );
assertEquals( "Nobody", group.getGroupName() );
assertEquals( 0, group.getPeople().length );
}
If there's a problem you can post a comment.