Hi. Looking at the code I can see there is support for JSon IDictionary
serialization, but when using NET2.0 dictionaries the code fails. I
have narrowed it down to the following code:
public class TestJsonClass
{
Dictionary<string, string> _stringArray = new Dictionary<string,
string>();
public Dictionary<string, string> StringArray
{
get { return _stringArray; }
set { _stringArray = value; }
}
}
...
TestJsonClass tjc = new TestJsonClass();
tjc.StringArray.Add("test", "testing");
string json = AjaxPro.JavaScriptSerializer.Serialize(tjc);
tjc =
(TestJsonClass)AjaxPro.JavaScriptDeserializer.DeserializeFromJson(json,
typeof(TestJsonClass));
During debugging I notice that the dictionary will be serialized using
IListConverter, and will then throw an exception in
IListConverter.Deserialize when trying to deserialize the json string;
(IListConverter.cs line 92)
if (!typeof(IList).IsAssignableFrom(t) || !(o is JavaScriptArray))
throw new NotSupportedException();
!typeof(IList).IsAssignableFrom(t) is true.
>From my debugging session, I can't see why IDictionaryConverter isn't
activated for the dictionary.
That leads me back to my question, should it work? Or should I write my
own converter for a generic Dictionary?
Thanks,
Trond Nilsen
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ajax.NET Professional" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/ajaxpro
The latest downloads of Ajax.NET Professional can be found at
http://www.ajaxpro.info/
Don't forget to read my blog at http://weblogs.asp.net/mschwarz/
-~----------~----~----~----~------~----~------~--~---