Convert JSON string to C #

I found two different answers to this question, one using JsonConvert (including JObject, JArray, JToken) and one using JavaScriptSerializer. Both turn out to be a bit outdated (especially the latest), and since I just found out that, for example, WebClient (which has been suggested by many) is outdated HttpClient, I'm not sure what to use (or if there is an even newer and preferred way.

I am not getting any hints of them with my intellisense, and so I suspect they are not that relevant.

I have a string that contains JSON formatted data. How do I get it into something workable in C #?

+3


source to share


1 answer


If I understand what you are asking, the short Json.NET answer with code examples:

http://james.newtonking.com/json/help/index.html



var json = "{email:'bob@gmail.com'}";
var user = JsonConvert.DeserializeObject<User>(json);

      

Is this what you are looking for?

+3


source







All Articles