I have following json coming from server
{
"contactList":[{
"contactName":"Jhon",
"address":null,
"phone":null,
"contactId":99932
}]
}
now when i am deserializing using JsonConvert.DeserializeObject<Response>(content)
i want following output
{
"contactList":[{
"contactName":"Jhon",
"contactId":99932
}]
}
i tried following code but its not working
JsonSerializerSettings jsonSettings = new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore,
MissingMemberHandling = MissingMemberHandling.Ignore
};
this is my Contact model
public class Contact
{
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public String address { set; get; }
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public String phone { set; get; }
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public String name { set; get; }
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public String id { set; get; }
}
model of Response
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public class Response
{
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public IList<SignodeMSA.Model.Master.Contact> contactsList { get; }
}
and i am deserializing after fetching it from server
Response responseData = await Task.Run(() => JsonConvert.DeserializeObject<Response>(content, jsonSettings));