I am calling a REST API and receives a response as JSON text with a format that JSON Editor https://jsoneditoronline.org/ cannot read either.
Part of the JSON text looks like this:
"{\"displayFieldName\":\"address\",\"fieldAliases\":{\"objectid\":\"objectid\",\"address_id\":\"adressutal\",\"address\":\"adressa\",\"house_no\":\"húsanr.\",\"house_digit\":\"húsatal\",\"house_letter\":\"húsastavur.\",\"street_id\":\"vegur ID\",\"street_name\":\"veganavn.\",\"zip\":\"postnr.\",\"city\":\"stað\",\"municipality\":\"kommuna\",\"cadastral_district\":\"markatalsbygd\",\"cadastral_no\":\"matr. nr.\",\"longitude\":\"longdarstig\",\"latitude\":\"breiddarsting\",\"google_streets_url\":\"vís á google streets\",\"address_city\":\"adressa og bygd\",\"cadastral_mslink\":\"mslink av matrikul\"},\"geometryType\":\"esriGeometryPoint\",\"spatialReference\":{\"wkid\":5316,\"latestWkid\":5316},\"fields\":[{\"name\":\"objectid\",\"type\":\"esriFieldTypeOID\",\"alias\":\"objectid\"},{\"name\":\"address_id\",\"type\":\"esriFieldTypeInteger\",\"alias\":\"adressutal\"},{\"name\":\"address\",\"type\":\"esriFieldTypeString\",\"alias\":\"adressa\",\"length\":60},{\"name\":\"house_no\",\"type\":\"esriFieldTypeString\",
The text contains a list of addresses with the following structure:
public class Point
{
public int X { get; set; }
public int Y { get; set; }
}
public class Address
{
public int objectid { get; set; }
public int address_id { get; set; }
public string address { get; set; }
public int house_no { get; set; }
public int house_digit { get; set; }
public int house_letter { get; set; }
public int street_id { get; set; }
public string street_name { get; set; }
public int zip { get; set; }
public string city { get; set; }
public int municipality { get; set; }
public int cadastral_district { get; set; }
public int cadastral_no { get; set; }
public int longitude { get; set; }
public int latitude { get; set; }
public string google_streets_url { get; set; }
public string address_city { get; set; }
public string cadastral_mslink { get; set; }
public Point Point { get; set; }
}
How can I deserialize such a JSON text?
What I have tried:
I have tried this code:
var objectList = JsonConvert.DeserializeObject
(jsonResponse);
but it does not work.