I have a noSQL database. When I'm trying to map the JSON data with C# class models, some of my data get mapped, but some don't.
Below is my Sample JSON format.
{
"J1D0GhKmzAT4gRn5VkfPKKVCfku2": {
"reports": {
"-KYbi7tbJoZJmCs8hcHy": {
"age": "0",
"description": "Test",
"incident": "Test",
"location": "Test"
},
"-KYbmoWJwzSSS0llsSZN": {
"age": "0",
"description": "Test",
"incident": "Test",
"location": "Test"
},
"-KYbszjzkYnH2N9xbFMJ": {
"age": "0",
"description": "Test",
"incident": "Test",
"location": "Test"
}
},
"user_info": {
"dob": "Feb 11, 2016",
"name": "Test",
"phone": "44444",
"sex": "Male",
"work": "llllll"
}
},
"JxmpIWWioFbg1Po4gXtV07pwDvX2": {
"reports": {
"-KYiiDRl7fYAPdav13h3": {
"age": "0",
"description": "Test",
"incident": "Test",
"location": "Test"
},
"-KYinWZeP7N24x8QUC6O": {
"age": "0",
"description": "Test",
"incident": "Test",
"location": "Test"
}
},
"user_info": {
"dob": "Feb 11, 2016",
"name": "Test",
"phone": "44444",
"sex": "Male",
"work": "llllll"
}
}
}
and My C# Class Models are as below
public class User
{
public user_info user_info { get; set; }
public reports reports { get; set; }
}
public class user_info
{
public string dob { get; set; }
public string name { get; set; }
public string phone { get; set; }
public string sex { get; set; }
public string work { get; set; }
}
public class reports
{
public List<reportInfo> reportInfo { get; set; }
}
public class reportInfo
{
public string age { get; set; }
public string description { get; set; }
public string incident { get; set; }
public string location { get; set; }
}
Here, when I try to map the JSON with C# classes, only the user_info
model gets populated for some reason. There is a matching property in JSON. But my reports model doesn't get populated, because it has some dynamic properties which is not getting mapped with model.
Please let me know where I am going wrong and the possible solution.
Thanks in advance.