-
Notifications
You must be signed in to change notification settings - Fork 254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deserialize without generic type-parameter but.. with.. Type parameter? #60
Comments
This isn't a bad idea, I'll see if I can't slip it into a future release. |
Awesome, thanks Kevin! (assuming you meant "can" instead of "can't" ;) ) |
…eric calls of Deserialize at a small tax; fixes kevin-montrose#60
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(). |
@dotjosh |
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 notifications@github.com
|
Good evening,
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))
{
var myTargetType = typeof(MyClass);
var result = JSON.Deserialize(input, myTargetType);
}
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,
-J
The text was updated successfully, but these errors were encountered: