[Mono-dev] Replicating System.Web.Script.Serialization bugs

R. Tyler Ballance tyler at monkeypox.org
Sun Oct 14 01:12:50 EDT 2007

On Oct 1, 2007, at 10:17 AM, Adar Wesley wrote:

> Hi Kosta and Tyler,
> Having worked on this code with Kosta and following this thread a  
> couple of questions come to my mind.
> 1. Are there any other types that need special care, besides  
> Nullable?  How about generic types?
>     As far as I remember, we don't have any tests with generics.   
> Are we missing anything else?
> 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...)

Coming back to this, since I'm hacking on it right now. A value of  
"xxx"  _will_ throw an InvalidCastException, whereas an empty string  
will not.

I think I might be overcomplicating this, the only possible valid  
JSON syntax for an empty value seems to be "", I've got the following  
patch that I'm waiting on "peer-review" to commit.

It handles the case in https://bugzilla.novell.com/show_bug.cgi? 
id=328836 with regards to mimicking the .NET behavior for empty JSON  
values with regards to Nullable types. It'll still throw on "xxx"  
values that are attempting to be converted to long/int/etc.

Konstantin, just say the word and it'll be committed, otherwise, I'm  
at a lose for solutions to handle this :-P

-R. Tyler Ballance

-------------- next part --------------
A non-text attachment was scrubbed...
Name: JavaScriptSerializer.328836.patch
Type: application/octet-stream
Size: 1162 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20071013/32299e73/attachment.obj 
-------------- 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/20071013/32299e73/attachment.bin 

More information about the Mono-devel-list mailing list