an API is returning a JSON that looks like this:
{
"html_attributions" : [],
"result" : {
"address_components" : [
{
"long_name" : "1-3",
"short_name" : "1-3",
"types" : [ "street_number" ]
},
{
"long_name" : "Acacia",
"short_name" : "Acacia",
"types" : [ "route" ]
},
{
"long_name" : "Alamos 2da Sección",
"short_name" : "Alamos 2da Secc",
"types" : [ "sublocality_level_1", "sublocality", "political" ]
},
{
"long_name" : "Santiago de Querétaro",
"short_name" : "Santiago de Querétaro",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Querétaro",
"short_name" : "Qro.",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "Mexico",
"short_name" : "MX",
"types" : [ "country", "political" ]
},
{
"long_name" : "76160",
"short_name" : "76160",
"types" : [ "postal_code" ]
}
]
},
"status" : "OK"
}
I wold like to access the "sublocality" object and read it's value which in this case is "alamos 2da secc". I know the JSON must first be parsed using JSON.parse but im not sure how to access a specific object. Is a for loop necessary? or is there a way i can match the type field for every object to be "sublocality"
Any assistance is appreciated.