0

So i have made an api call and received this object back

[
    {
        "$type": "foo.Api.bar.Entities.foo, foo.Api.bar.Entities",
        "id": "a2",
        "displayName": "A2",
        "statusSeverity": "Good",
        "statusSeverityDescription": "No Exceptional Delays",
        "bounds": "[[-0.0857,51.44091],[0.17118,51.49438]]",
        "envelope": "[[-0.0857,51.44091],[-0.0857,51.49438],[0.17118,51.49438],[0.17118,51.44091],[-0.0857,51.44091]]",
        "url": "/Road/a2"
    }
]

I have no clue what

"$type": "foo.Api.bar.Entities.foo, foo.Api.bar.Entities",

is and i'm not sure how to design my model to take it in?

public class Road
{
    public string Id { get; set; }
    public string DisplayName { get; set; }
    public string StatusSeverity { get; set; }
    public string StatusSeverityDescription { get; set; }
    public string Bounds { get; set; }
    public string Envelope { get; set; }
    public string Url { get; set; }
}

what is $"type" and how should i go about trying to deserialize it into my model, which i will then map into my DTO?

dros
  • 1,217
  • 2
  • 15
  • 31
  • Possible duplicate of [how to deserialize JSON into IEnumerable with Newtonsoft JSON.NET](https://stackoverflow.com/questions/6348215/how-to-deserialize-json-into-ienumerablebasetype-with-newtonsoft-json-net) – devNull Dec 08 '19 at 22:35

1 Answers1

0

The $ sign related to the data source not to JSON itself, to deserialize it use the following :

[JsonProperty(PropertyName = "$type")]
public string PropertyName{ get; set; }
Cyber Progs
  • 3,656
  • 3
  • 30
  • 39