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

Cheers,
-R. Tyler Ballance

Attachment: JavaScriptSerializer.328836.patch
Description: Binary data

Attachment: PGP.sig
Description: This is a digitally signed message part

_______________________________________________
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list

Reply via email to