I am trying to deserialize an HTTP Request to a C# POCO class.
The JSON is:
{
"applicationId":"4284f0b0-61f9-4a9d-8894-766f7b9605b5",
"deviceId":"testdevice22",
"messageType":"cloudPropertyChange",
"properties":[
{"name":"CustomerID","value":202},
{"name":"DeviceSerialNumber","value":"devicesa999"},
{"name":"Location","value":{
"alt":0,
"lat":41.29111465188208,
"lon":-80.91897192058899
}}
],
}
The POCO is:
public class CustomEventModel
{
public string applicationId { get; set; }
public string deviceId { get; set; }
public List<PropertyAttribute> properties { get; set; }
}
public class PropertyAttribute
{
public string name { get; set; }
public string value { get; set; }
}
In my Function App I have:
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
var propertyChangeData = JsonConvert.DeserializeObject<CustomEventModel>(requestBody);
The Exception Message is: 2022-05-27T23:14:42.141 [Error] Error in CustomEventModel: Unexpected character encountered while parsing value: {. Path 'properties[7].value', line 1,
It is all related to the Location item. How do I solve this?