This project is read-only.

Can't deserialize custom classes inheriting from custom lists

Feb 19, 2015 at 1:00 AM
Okay, so the scenario is quite simple. I have the following code:
Public Class MyCustomEntry
    Public X As String
    Public Y As String
End Class

Public Class MyCustomEntries
    Inherits List(Of MyCustomEntry)
End Class
Serializing MyCustomEntries works fine. But deserializing the resulting string doesn't. Keep in mind I don't include the types in the result because I do not wish to expose my types to the public. To deserialize I define my type when deserializing but still I get the following:

_An unhandled exception of type 'System.InvalidCastException' occurred. Additional information: Unable to cast object of type 'System.Collections.Generic.List`1[System.Object]' to type 'MyCustomEntries'._

I tried implementing a fix on my own for this but failed. JSON.NET handles this perfectly, but I really would like to switch to fastJSON. This is the only part that doesn't work for me.
Feb 24, 2015 at 10:00 AM
Currently inheriting from List is not supported in fastJSON however you can just use List(Of MyCustomEntry) which works fine.