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

R. Tyler Ballance tyler at monkeypox.org
Thu Sep 27 05:25:33 EDT 2007


On Sep 26, 2007, at 12:39 AM, Andrés G. Aragoneses [ knocte ] wrote:

> R. Tyler Ballance escribió:
>> [...]
>> Without providing compatibility for MS.NET, the only alternatives
>> seem to be some application specific hacks, either with crazy
>> properties as mentioned above, or using Nullable types (which we
>> don't yet support in Mono right?)
>
> Hey, I think Mono has support for Nullables since much time ago.

Unfortunately, I tried this in Mono, and our  
System.Web.Script.Serialization barfs on Nullable types :(

Fortunately, .NET doesn't! Alas there is hope :)

I've attached my modified JsonTest class (attached), and here's the  
output:

Microsoft .NET 2.0.5:
--------------------------------------
Testing for empty values in JSON with this string:
{"int_key" : ""}
int_key =

--------------------------------------

Mono version 1.2.5 (/trunk/ r86375)
--------------------------------------
[mono] \w @ mono JsonTest.exe
Testing for empty values in JSON with this string:
{"int_key" : ""}

Unhandled Exception: System.InvalidCastException: Unknown target  
conversion type
   at System.Convert.ToType (System.Object value, System.Type  
conversionType, IFormatProvider provider) [0x00000]
   at System.Convert.ChangeType (System.Object value, System.Type  
conversionType) [0x00000]
   at  
System.Web.Script.Serialization.JavaScriptSerializer.ConvertToType  
(System.Type type, System.Object obj) [0x00000]
   at  
System.Web.Script.Serialization.JavaScriptSerializer.ConvertToObject  
(IDictionary`2 dict, System.Type type) [0x00000]
   at  
System.Web.Script.Serialization.JavaScriptSerializer.ConvertToType  
(System.Type type, System.Object obj) [0x00000]
   at  
System.Web.Script.Serialization.JavaScriptSerializer.ConvertToType 
[JsonObject] (System.Object obj) [0x00000]
   at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize 
[JsonObject] (System.String input) [0x00000]
   at JsonTests.JsonTest.Main (System.String[] args) [0x00000]
[mono] \w @
--------------------------------------

I've also reported the bug here: https://bugzilla.novell.com/ 
show_bug.cgi?id=328836


Cheers


-------------- next part --------------
A non-text attachment was scrubbed...
Name: JsonTest.cs
Type: application/octet-stream
Size: 911 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20070927/a306f5b5/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/20070927/a306f5b5/attachment.bin 


More information about the Mono-devel-list mailing list