This only happens when the JSON looks like:
{"thisIsANumber":2}
When the case is that it works well:
{"thisIsANumber":"2"}
Yes and no.
JSON (RFC 4627) doesn't make any restriction on the value range for
numbers, so the org.json library is right in not serializing longs
into strings. But JSON also says "An implementation may set limits on
the range of numbers." Given that numbers in JavaScript are IEEE 754
binary64 values (equivalent of a Java double), and JsonUtils (used by
AutoBeans) uses native JSON.parse() or a fallback on eval(), then
numbers in the parsed JSON have to fit in a JS Number / Java double.
Because all Java longs do not fit in a Java double, AutoBean encodes
longs as strings, and therefore expects them to be strings (or in the
proposed patch, follows Postel's law by always serializing as strings,
but accepting numbers and strings for deserialization.
> The problem of unserializing collections with AutoBean codex persists.
> The workaround is to use a List. Then it works well.
AutoBeans only supports Lists and Sets as collection types:
http://code.google.com/p/google-web-toolkit/wiki/AutoBean#Property_types