Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Deserialize without generic type-parameter but.. with.. Type parameter? #60
I was wondering whether there is any existing or a planned way to deserialize a string or stream into an object instance, without providing the target type via a type parameter, but via the "good old" Type parameter in the Json.Deserialize(..) signature, e.g.:
using(var input = new StringReader(myString))
I know it doesn't exist atm and I would not want to use reflection to call your existing generic method via reflection to achieve that (ick: http://stackoverflow.com/questions/2107845/generics-in-c-using-type-of-a-variable-as-parameter) unless I had to. Right now I am attempting to plug Jil into NancyFx as a custom (De-)Serializer and their IBodySerializer signature only provides the target type as a plain Type parameter value, not as a type parameter.
Is there any chance that might be added to Jil as an alternative to the existing JSON.Deserialize method?
Cheers and thanks,
pushed a commit
Sep 12, 2014
Is there a way to serialize and pass the type too? I have a collection of objects that are used as their base type, so the generic method isn't serializing any properties defined on the subclass because the type is inferred from the generic signature of JSON.Serialize().
Thank you - yeah I saw that, didn't realize it was applicable. I'll have
On Thu, Jun 25, 2015 at 9:44 PM, kevin-montrose firstname.lastname@example.org