Click here to Skip to main content
15,914,111 members

Comments by Member 11415004 (Top 2 by date)

Member 11415004 28-Jan-18 13:20pm View    
Hi here is my deserialize method:

[DataContract]
public class JsonDataContractObject
{
public string ToJson()
{
DataContractJsonSerializer ser = new DataContractJsonSerializer(this.GetType());
Stream s = new MemoryStream();
ser.WriteObject(s, this);
s.Position = 0;
StreamReader sr = new StreamReader(s);
return sr.ReadToEnd();
}
}

And i get data from web api using http client. If i have root object then this "DataContractJsonSerializer" method working fine but my json response dont have root object so idea. Please help.
Member 11415004 28-Jan-18 13:17pm View    
Hi, Thanks for the update. But json result from web api so i cannot change. Can you help to fix this? and i am using DataContractJsonSerializer. My code:

[DataContract]
public class JsonDataContractObject
{
public string ToJson()
{
DataContractJsonSerializer ser = new DataContractJsonSerializer(this.GetType());
Stream s = new MemoryStream();
ser.WriteObject(s, this);
s.Position = 0;
StreamReader sr = new StreamReader(s);
return sr.ReadToEnd();
}
}