OK, this is fixed. When JSONSerializer encounters a key that references a non-existent bean property, that value will be ignored.
On Nov 23, 2010, at 1:42 AM, Bill van Melle wrote: > Yes, you understand correctly. > > On Mon, Nov 22, 2010 at 6:44 PM, Greg Brown <[email protected]> wrote: > So, is the issue that your JSON data contains a key that doesn't exist in the > bean class, and a SerializationException is thrown when processing this key? > For example, if I have the following JSON: > > { foo: "bar" } > > and the "foo" property does not exist in the bean, you get the exception? If > so, it seems reasonable to discard "foo" in this case. Let me know if my > description of the problem is not correct. > > G > > > > On Nov 22, 2010, at 9:21 PM, Bill van Melle wrote: > >> And my experience with the preceding now enables me to answer my original >> question -- you debug serializer errors by attaching the Pivot source, set >> exception breakpoints on the exceptions that are raised, and poke around on >> the stack to get some idea of where in the input the deserialization fell >> over. >> >> Doing this, I discovered that JSONSerializer is intolerant of unknown >> fields. Other serializers I've used are perfectly happy to encounter a >> field that isn't declared in the user object, and simply throw away the >> corresponding value. I think it would be great if Pivot did the same. Yes, >> I can declare all the fields that the server is known to return today, even >> if I have no use for them, but I'll be in trouble if new fields (that the >> implementors assume I can just ignore) get added later. >> >> Anyway, I found at least two kinds of cryptic errors that occur when an >> unknown field is encountered: SerializationException -- "Cannot convert >> <some primitive json type> to null." (several places in the Pivot code), and >> NullPointerException if the value is an array. > >
