Currently, I am receiving a dynamic JSON response from an API which I am trying to parse. An example of the JSON that is received looks as follows:
{
"data": [
{
"Id": "XXXXXXXXXXXXXXXXXXXXXXXX",
"IsActive": true,
"DateCreated": "2017-11-09T00:01:49.827Z",
"DateModified": "2017-11-09T00:01:49.827Z",
"IsDeleted": false,
"Uid": "XXXXXXXXXXXXXXXXXXXXXXXX",
"CustomObject": {
"customdata1": " Store my customdata1 value",
"customdata2": " Store my customdata2 value"
}
}
],
"Count": 1
}
In the above JSON, while serializing, I want CustomObject to be mapped to a string in the C# object. Below is an example of the object structure I want.
[System.Runtime.Serialization.DataContract]
public class CustomObjectData
{
[System.Runtime.Serialization.DataMember]
public string Id { get; set; }
[System.Runtime.Serialization.DataMember]
public bool IsActive { get; set; }
[System.Runtime.Serialization.DataMember]
public string DateCreated { get; set; }
[System.Runtime.Serialization.DataMember]
public string DateModified { get; set; }
[System.Runtime.Serialization.DataMember]
public bool IsDeleted { get; set; }
[System.Runtime.Serialization.DataMember]
public string Uid { get; set; }
[System.Runtime.Serialization.DataMember]
public string CustomObject { get; set; }
}
[System.Runtime.Serialization.DataContract]
public class CustomObjectDataHolder
{
[System.Runtime.Serialization.DataMember]
public List<CustomObjectData> data { get; set; }
[System.Runtime.Serialization.DataMember]
public int Count { get; set; }
}
I am trying to develop this as a plugin for CRM, so I am unable to use other third party JSON serializers like NewtonSoft.