Migrate from GitHub to SourceForge with this tool. Check out all of SourceForge's recent improvements.
Close

#17 JSONDeserializer error on empty array

1.9.2
closed-fixed
5
2010-10-15
2010-05-19
Anonymous
No

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)
...

Discussion

  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous

    Anonymous - 2010-05-25

    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
  • Charlie Hubbard

    Charlie Hubbard - 2010-10-15

    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.

     
  • Charlie Hubbard

    Charlie Hubbard - 2010-10-15
    • status: open --> closed-fixed
     

Log in to post a comment.