I'm using google's geocode API to fetch data based on ZIP code that I pass like following:
http://maps.googleapis.com/maps/api/geocode/json?address=97001&sensor=true
I get a result like this:
{
"results" : [
{
"address_components" : [
{
"long_name" : "97001",
"short_name" : "97001",
"types" : [ "postal_code" ]
},
{
"long_name" : "Antelope",
"short_name" : "Antelope",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Oregon",
"short_name" : "OR",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "United States",
"short_name" : "US",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "Antelope, OR 97001, USA",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 45.0835979,
"lng" : -120.476616
},
"southwest" : {
"lat" : 44.801399,
"lng" : -120.91835
}
},
"location" : {
"lat" : 44.9552895,
"lng" : -120.6265837
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 45.0835979,
"lng" : -120.476616
},
"southwest" : {
"lat" : 44.801399,
"lng" : -120.91835
}
}
},
"place_id" : "ChIJhZMDGc0ovFQRBev1yy22nAk",
"types" : [ "postal_code" ]
}
],
"status" : "OK"
}
Now this is good, but I'd like to pick out only the record from "addres_component" where types equals to:
"types" : [ "administrative_area_level_1", "political" ]
I can do something like this to fetch the value:
JObject.Parse(myJson)["keyhere"].ToString();
But how do I actually check whether the type for the values short_name and long_name is the one that I put above??
How can I achieve this using JObject class?