I\'m trying to consume SmartyStreets JSON LiveAddress API and I\'m having some difficulties. I will admit that I\'m not too familiar with JSON. Anyways, I\'ve tried a few di
I prefer to use dynamic
object in these cases (No need for creating ugly classes)
such as:
dynamic jsonObj = JsonUtils.JsonObject.GetDynamicJsonObject(json);
foreach(var item in jsonObj)
{
Console.WriteLine(item.delivery_line_1 + ", " +
item.last_line + ", " +
item.metadata.county_name + ", " +
item.components.street_name + ", " +
item.components.city_name );
}
Here is the source for Dynamic Json Object (just copy & paste to your project) and some samples
PS: This is your json string in more readable format
[
{
"input_index": 0,
"candidate_index": 0,
"delivery_line_1": "1600 Amphitheatre Pkwy",
"last_line": "Mountain View CA 94043-1351",
"delivery_point_barcode": "940431351000",
"components": {
"primary_number": "1600",
"street_name": "Amphitheatre",
"street_suffix": "Pkwy",
"city_name": "Mountain View",
"state_abbreviation": "CA",
"zipcode": "94043",
"plus4_code": "1351",
"delivery_point": "00",
"delivery_point_check_digit": "0"
},
"metadata": {
"record_type": "S",
"county_fips": "06085",
"county_name": "Santa Clara",
"carrier_route": "C058",
"congressional_district": "14"
},
"analysis": {
"dpv_match_code": "Y",
"dpv_footnotes": "AABB",
"dpv_cmra": "N",
"dpv_vacant": "N",
"ews_match": false,
"footnotes": "N#"
}
}
]