Open GoogleCodeExporter opened 8 years ago
There is support in the JSON mapper to map the same FB field name to multiple
Java types. For example, you might try to map to a class like this:
public class QueryResult {
@Facebook("attachment")
private List<String> emptyAttachments = new ArrayList<String>();
@Facebook("attachment")
private QueryAttachment queryAttachment;
... getters/setters elided
}
public class QueryAttachment {
@Facebook("object_id")
private String objectId;
... getters/setters elided
}
Let me know if that solves your problem.
Original comment by mark.a.a...@gmail.com
on 31 Mar 2011 at 5:38
To clarify a bit: in the case of the same FB field name being mapped to
multiple Java fields the mapper tries to map each field name. If the mapping
fails, the field will be null and no exception will be thrown (this is in
contrast to the normal behavior seen for fields that are not multiple-mapped,
where an exception is thrown on failed mapping).
Original comment by mark.a.a...@gmail.com
on 31 Mar 2011 at 5:40
I'm sure that solution would work, and I'm already using another workaround to
coax Facebook into returning consistent results. The underlying problem is with
the inconsistent JSON that Facebook returns, and is very similar to the problem
in Issue #76, so I thought you might want to address it as a special case in
the library code as you did there.
Original comment by blick...@gmail.com
on 31 Mar 2011 at 5:46
I might in the future; thanks for the suggestion. Once the enhancement was
added that allows multiple mapping, my plan was to have further wackiness like
what you're seeing addressed by that rather than special-casing the JSON mapper
(the existing special-casing has been left intact for backwards compatibility).
But yeah, if FB makes more of a habit of returning inconsistent JSON like this,
then my hand will be forced and I'll probably make the change directly in the
JSON mapper.
I'll keep this issue opened for an unschedule future release. Thanks for
letting me know about it!
Original comment by mark.a.a...@gmail.com
on 31 Mar 2011 at 5:56
Original issue reported on code.google.com by
blick...@gmail.com
on 24 Mar 2011 at 5:25