c# - Which Json deserializer renders IList<T> collections? -


I am trying to desegregate an object model to Jason, where the collection is IList < T & gt; Type

The actual deserializing is here:

  JavaScriptSerializer serializer = new JavaScriptSerializer (); Return Serializer. Dairyialize & lt; IList & lt; Contacts & gt; & Gt; (New Streamer (Normal.GetEmbeddedFile ("contacts.json")). ReadToEnd ()));  

Before I am getting an exception, you should know what the underlying conversion is, it is the type of contact :

  public class contacts {public id id {get; Set; } Public string name {get; Set; } Public LazyList & lt; ContactDetail & gt; Details {Receive; Set; } // public list & lt; ContactDetail & gt; Details {Receive; Set; }}  

and this is ContactDetail type:

  public class ContactDetail {public entry id {get; Set; } Public int commandindex {received; Set; } Public string name {get; Set; } Public string value {get; Set; }}  

LazyList & lt; T & gt; The important thing to know with is that it is IList & lt; T & gt; :

  Public category LazyList & lt; T & gt; : ILIIT & lt; T & gt; {Private IQueryable & lt; T & gt; _query = null; Private IList & lt; T & gt; _inner = null; Private Ent? _CacheCache = null; Public LazyList () {this._in = New list & lt; T & gt; (); } Public LazyList (IList  Internal} {this._inner = inner; } Public LazyList (IQueryable & lt; T & gt; query) {if (query == null) New ArgumentNullException () Throw; This._query = query; }  

Now this LazyList & lt; T & gt; The definition of class was ok unless I tried to disassemble Jason in it System.Web.Script.Serialization.JavaScriptSerializer list to list & lt; T & gt; wants to serial, which understands the meaning of its age, but I need it iiLIT So they have my LazyList & lt; T & gt; (at least this is where I think I'm going wrong).

I get this exception:

  System.ArgumentException: object type 'System.Collections.Generic.List`1 [ContactDetail]' to 'LazyList1' [ContactDetail ] Can not be typed. ..  

When I list & lt; ContactDetail & gt; Try to use my contact type (as you can comment on), then it starts working, but I list & lt; T & gt; I do not want to use 's' LazyList & lt; T & gt; Tried to inherit with the list , but the list the internal T [] was a nightmare for my implementation and I just list anywhere in my model & lt; T & gt; does not want to bloat.

I did not even benefit from some libraries (it is possible that I can not use them for my full potential. I repeat the quoted code at the top of this question more or less than the context Tried.)

I do not know what to try now. Do I go with another deserializer? Do I tweak myself deserializing? Will deserializer change me to change my type? Do I need to worry more about the underlying molding or just implement another interface? It is not possible to deserialize it directly for an interface, because the interface is only a contract JavaScriptSerializer has something to do with

  var list = serializer.Deserialize & lt; IList & lt; Contact & gt; & Gt; (...); Var lazyList = New LazyList (list);  

Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -