Given the following json document, what would be the best way to convert it to a valid object using a Converter? The trick comes in that the source json has the value
property as string where it should be serialized as a float?
{
"metric": "metric",
"operator": "GREATER_THAN",
"value": "1",
"status": "OK",
"errorThreshold": "1"
}
The resulting c# object:
public class Condition
{
[JsonPropertyName("errorThreshold")]
public string ErrorThreshold { get; set; }
[JsonPropertyName("metric")]
public string Metric { get; set; }
[JsonPropertyName("operator")]
public string Operator { get; set; }
[JsonPropertyName("status")]
public string Status { get; set; }
[JsonPropertyName("value")]
public double? Value { get; set; }
}
I'm toying here with a converter that makes use of reflection to do this, but this seems like using a shotgun to kill a earthworm.
Are there any more commonly established/recommended ways in doing this?