I'm relatively new to dealing with JSON. But have successfully created a few classes that return exactly what I want. However, this response is baffling me.
I have reviewed and attempted the various examples on the site to convert my JSON response into a class. However, I continue to get run-time errors. Any pointers on where I'm going wrong would be appreciated.
JSON Response
{
"locationResponse": {
"locations": [
"E911AID:93a6:2db4:0589:261d,streetDir:NE,street:89th,zip:98052,city:Redmond,streetNameSuffix:St,name:Jonathon Doe,state:WA,houseNum:23619",
"E911AID:93a6:2db4:0589:261d,streetDir:NE,street:89th,zip:98052,city:Redmond,streetNameSuffix:St,name:Jon Doe,state:WA,houseNum:23619",
"ad1c:2dbf:fadf:2e87",
"E911AID:93a6:2db4:0589:261d,streetDir:NE,street:89th,zip:98052,city:Redmond,streetNameSuffix:St,name:John Doe,state:WA,houseNum:23619",
"E911AID:93a6:2db4:0589:261d,streetDir:NE,street:89th,zip:98052,city:Redmond,streetNameSuffix:St,name:JJ Doe,state:WA,houseNum:23619"
]
}
}
Class Definition
[Serializable]
public class locationResponseResponse
{
public locationResponse locationResponse { get; set; }
}
[Serializable]
public class locationResponse
{
public location[] locations { get; set; }
}
[Serializable]
public class location
{
public string E911AID { get; set; }
public string streetDir { get; set; }
public string street { get; set; }
public string zip { get; set; }
public string city { get; set; }
public string streetNameSuffix { get; set; }
public string name { get; set; }
public string state { get; set; }
public string houseNumber { get; set; }
}
Deserialize Snippet
public locationResponseResponse GetlocationResponseResponse(string jsonString)
{
locationResponseResponse _response = new locationResponseResponse();
if (!string.IsNullOrEmpty(jsonString))
{
JavaScriptSerializer ser = new JavaScriptSerializer();
_response = ser.Deserialize<locationResponseResponse>(jsonString);
}
return _response;
}
Run-time Error Received
No parameterless constructor defined for type of BlackFlagAPI.locationResponse[]
.