C# Deserialize JSON to any type method -



C# Deserialize JSON to any type method -

so have method (the sec block of code) convert json c sharp object works but

what want able tell method type of object need cast to

//not real code public static object jsontoobj(string i_json, typeof(home)) //will homecoming home object //not real code //real code public static object jsontoobj(string i_json) { serializer = new javascriptserializer(); object io_obj = serializer.deserialize<object>(i_json); homecoming io_obj; } //real code

public static t jsontoobj<t>(string i_json) { var serializer = new javascriptserializer(); t io_obj = serializer.deserialize<t>(i_json); homecoming io_obj; }

you can phone call this:

home h = jsontoobj<home>(json);

c# json javascriptserializer

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -