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

Andreia Gaita shana.ufie at gmail.com
Tue Sep 25 06:23:04 EDT 2007


On 9/25/07, Konstantin Triger <kostat at mainsoft.com> wrote:
> 1. For value types: since there is no notion of 'null' value (unlike many dymanic languages) it would be very hard to differentiate between the 'default' and deserialized values if they are equal. (If you have a field of type 'Int32' and its value after deserialization is 0, where is it from?!)

Actually, that problem was solved in the xml deserializer by having it
set a helper property marking whether the value had originated from
the xml or was merely a default one. Also, if javascript is weakly
typed, it doesn't make sense to force initialization of variables if
they are of a certain type, as that concept doesn't apply to it. So,
in theory, this value pair should deserialize correctly.

Of course, all that is moot, since the ms.net deserializer blows up on
it. 99% bug compatibility and all that...
One workaround would be to slightly massage the script prior to
deserialization. A regexp should remedy things, maybe?

> 2. For String type: should {"some_key" : ""} be deserialized to null or empty string?

Same thing as above - the value should not determine whether something
was deliberately filled in or if it is just at the default value.

andreia gaita



More information about the Mono-devel-list mailing list