Create a class like this:
public class Data
{
public string Id {get; set;}
public string Name {get; set;}
public string First_Name {get; set;}
public string Last_Name {get; set;}
public string Username {get; set;}
public string Gender {get; set;}
public string Locale {get; set;}
}
(I'm not 100% sure, but if that doesn't work you'll need use [DataContract]
and [DataMember]
for DataContractJsonSerializer
.)
Then create JSonSerializer
:
private static readonly XmlObjectSerializer Serializer = new DataContractJsonSerializer(typeof(Data));
and deserialize object:
// convert string to stream
byte[] byteArray = Encoding.UTF8.GetBytes(contents);
using(var stream = new MemoryStream(byteArray))
{
(Data)Serializer.ReadObject(stream);
}