Generic List on the Compact Framework

Oct 30, 2009 at 9:28 AM

Hi folks,

I'm starting studying the possibilities to use the Json.NET Library for data transfert between a webservice and a WM application. I already read the documentation and see many examples of Serialization / Deserialization, and it works really fine.

I'm writing you because i saw an interesting example about Serializing/ Deserializing a collection (http://james.newtonking.com/projects/json/help/SerializingCollections.html).

I tried to create a simple example with a list of string (List<String>) but i got a NotSupportedException. I think it's due to some CF limitations.

Is it a limited feature ? How can i do ?

List<String> strings = new List<String>();

strings.Add("str_1");
strings.Add("str_2");
strings.Add("str_3");

JsonConvert.SerializeObject(strings);

When deserializing an list of string, i still have the same problem. Behind is a Json string example of what i would like to deserialize

 

json = "{strings:["str_1", "str_2", "str_3"]}";

 

 

 

List<String> strings = JsonConvert.DeserializeObject<ListString>(json);

 

 

I've also found that the array of string (string[]) works really fine and it could be an alternative to my problem. I tried to create a class that inherits from List<String> and it also worked :) 

It's very strange to me, could you explain me this ?

 

Thanks a lot for your time,

 

Coordinator
Nov 2, 2009 at 7:30 AM

Could you post the full exception trace from your NotSupportedException?