[Mono-dev] Replicating System.Web.Script.Serialization bugs
R. Tyler Ballance
tyler at monkeypox.org
Mon Oct 1 14:20:40 EDT 2007
On Oct 1, 2007, at 10:47 AM, Konstantin Triger wrote:
> >2. I was trying to think of a good strategy for implementing this,
> and havn't made up my mind yet.
>
> > I agree with Kosta that the try, catch approach is not the
> best way. I think something a bit more fine grained
>
> > should be used. What would happen if the value is "xxx" and
> the type is "int?"? This should probably
>
> > throw the error and not silently assign the null value.
> (Requires a test with MS code...)
>
>
>
> That's what I understood Tyler did and got null… Do I understand
> correctly?
My experiments weren't with JSON that actually was a string (i.e.
"xxx") being Convert.ToInt32()'d, it was the fact that most JSON API
providers denote any empty value with an empty string (i.e. "") Which
in our current serializer, does a check in Convert.ToInt32/Int64 such
that str.Length > 0, and throws an exception, instead of handling the
nullable type that I was passing it..
I'm not sure if the fix is in Convert.ChangeType to handle Nullable
types properly, or if it's specific to
System.Web.Script.Serialization. I didn't have the time to test this
further.
Cheers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20071001/ba351256/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20071001/ba351256/attachment.bin
More information about the Mono-devel-list
mailing list