I have my class defined as:
public class BusinessStatusHistory
{
[JsonProperty("statusDate")]
public string StatusDate { get; set; }
[JsonProperty("addInfo")]
public object AddInfo { get; set; }
}
object AddInfo can be a string or an anonymous object.
In my controller, I retrieve a list of BusinessStatusHistory and I can see the value for addInfo pop up:
When I return the response in this line: return Ok(result);
the value for addInfo is empty if it is an object and it shows if it is a string.
This is a sample response:
2
Answers
JObject doesn’t get recognized. You could try use
ExpandoObject
to parse the "AddInfo" to be recognized, Try following:Test result