bobolounna / restfb

Automatically exported from code.google.com/p/restfb
0 stars 0 forks source link

Unexpected "comments":[] in response #76

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Facebook now returns field "comments":[] in response for Post's, and that 
breaks:

Exception in thread "main" com.restfb.FacebookJsonMappingException: JSON is an 
array but is being mapped as an object - you should map it as a List instead. 
Offending JSON is '[]'.
    at com.restfb.DefaultJsonMapper.toJavaObject(DefaultJsonMapper.java:135)
    at com.restfb.DefaultJsonMapper.toJavaType(DefaultJsonMapper.java:476)
    at com.restfb.DefaultJsonMapper.toJavaObject(DefaultJsonMapper.java:208)

To fix it, I would add

    if (json.equals("[]")) 
        return null;

in DefaultJsonMapper.toJavaObject(String json, Class<T> type)

Original issue reported on code.google.com by ikabi...@gmail.com on 15 Sep 2010 at 9:00

GoogleCodeExporter commented 8 years ago
And here you should find a lot of examples of this new FB "feature":

https://graph.facebook.com/vodafoneES/feed?limit=100&access_token=...

j-d

Original comment by huillam@gmail.com on 15 Sep 2010 at 10:39

GoogleCodeExporter commented 8 years ago
Thanks again to the both of you for the bug report and the repro information.

Hopefully will get a 1.5.4 release with a fix out tomorrow.

Original comment by mark.a.a...@gmail.com on 15 Sep 2010 at 10:23

GoogleCodeExporter commented 8 years ago
Fixed (well, worked around) and released.

Original comment by mark.a.a...@gmail.com on 16 Sep 2010 at 3:19