mgholam / fastJSON

Smallest, fastest polymorphic JSON serializer
https://www.codeproject.com/Articles/159450/fastJSON-Smallest-Fastest-Polymorphic-JSON-Seriali
MIT License
478 stars 148 forks source link

Can not parse generic classes #135

Open emrahbabayigit opened 2 years ago

emrahbabayigit commented 2 years ago

I checked source code. The lookuptable was created only for CreditData. Because of that Response is not parsing

Simple example:

var r = fastJSON.JSON.ToObject<Response<CreditData>>("{\"data \":{\"Credit \":10},\"Error\":\"noerror\"}");
Debug.Assert(r.Error != null);
Debug.Assert(r.data != null);

public class Response<T>
{
  public T data { get; set; }
  public string Error { get; set; }
}

public class CreditData
{
   public int Credit { get; set; }
}