Reputation: 487
I'm trying to get the full jSON response from google geocoding API so I can test the result "status".
From the Docs:
responsePath: an optional JSONPath applied to the HTTP body. See https://github.com/s3u/JSONPath for syntax of JSON paths.
So I used "responsePath":"$..*" but it gets the response all messed up.
Example:
[
[
{
"address_components":[
{
"long_name":"Caracas",
"short_name":"CCS",
"types":[
"locality",
"political"
]
},
{
"long_name":"Libertador",
"short_name":"Libertador",
"types":[
"administrative_area_level_2",
"political"
]
},
{
"long_name":"Capital District",
"short_name":"Dto. Capital",
"types":[
"administrative_area_level_1",
"political"
]
},
{
"long_name":"Venezuela",
"short_name":"VE",
"types":[
"country",
"political"
]
}
],
"formatted_address":"Caracas, Venezuela",
"geometry":{
"bounds":{
"northeast":{
"lat":10.5401335,
"lng":-66.7179533
},
"southwest":{
"lat":10.39665,
"lng":-67.0627784
}
},
"location":{
"lat":10.4696404,
"lng":-66.8037185
},
"location_type":"APPROXIMATE",
"viewport":{
"northeast":{
"lat":10.5401335,
"lng":-66.7179533
},
"southwest":{
"lat":10.39665,
"lng":-67.0627784
}
}
},
"place_id":"ChIJB0iCza1YKowRg4SZCq4u3ZM",
"types":[
"locality",
"political"
]
},
{
"address_components":[
{
"long_name":"Venezuela",
"short_name":"VE",
"types":[
"country",
"political"
]
}
],
"formatted_address":"Venezuela",
"geometry":{
"bounds":{
"northeast":{
"lat":12.4866941,
"lng":-59.805666
},
"southwest":{
"lat":0.647529,
"lng":-73.351558
}
},
"location":{
"lat":6.42375,
"lng":-66.58973
},
"location_type":"APPROXIMATE",
"viewport":{
"northeast":{
"lat":14.470409,
"lng":-59.80378
},
"southwest":{
"lat":-4.1438179,
"lng":-79.0255611
}
}
},
"place_id":"ChIJAdjLNstTKIwR003VfFjyoNw",
"types":[
"country",
"political"
]
}
],
"OK",
{
"address_components":[
{
"long_name":"Caracas",
"short_name":"CCS",
"types":[
"locality",
"political"
]
},
{
"long_name":"Libertador",
"short_name":"Libertador",
"types":[
"administrative_area_level_2",
"political"
]
},
{
"long_name":"Capital District",
"short_name":"Dto. Capital",
"types":[
"administrative_area_level_1",
"political"
]
},
{
"long_name":"Venezuela",
"short_name":"VE",
"types":[
"country",
"political"
]
}
],
"formatted_address":"Caracas, Venezuela",
"geometry":{
"bounds":{
"northeast":{
"lat":10.5401335,
"lng":-66.7179533
},
"southwest":{
"lat":10.39665,
"lng":-67.0627784
}
},
"location":{
"lat":10.4696404,
"lng":-66.8037185
},
"location_type":"APPROXIMATE",
"viewport":{
"northeast":{
"lat":10.5401335,
"lng":-66.7179533
},
"southwest":{
"lat":10.39665,
"lng":-67.0627784
}
}
},
"place_id":"ChIJB0iCza1YKowRg4SZCq4u3ZM",
"types":[
"locality",
"political"
]
},
{
"address_components":[
{
"long_name":"Venezuela",
"short_name":"VE",
"types":[
"country",
"political"
]
}
],
"formatted_address":"Venezuela",
"geometry":{
"bounds":{
"northeast":{
"lat":12.4866941,
"lng":-59.805666
},
"southwest":{
"lat":0.647529,
"lng":-73.351558
}
},
"location":{
"lat":6.42375,
"lng":-66.58973
},
"location_type":"APPROXIMATE",
"viewport":{
"northeast":{
"lat":14.470409,
"lng":-59.80378
},
"southwest":{
"lat":-4.1438179,
"lng":-79.0255611
}
}
},
"place_id":"ChIJAdjLNstTKIwR003VfFjyoNw",
"types":[
"country",
"political"
]
},
[
{
"long_name":"Caracas",
"short_name":"CCS",
"types":[
"locality",
"political"
]
},
{
"long_name":"Libertador",
"short_name":"Libertador",
"types":[
"administrative_area_level_2",
"political"
]
},
{
"long_name":"Capital District",
"short_name":"Dto. Capital",
"types":[
"administrative_area_level_1",
"political"
]
},
{
"long_name":"Venezuela",
"short_name":"VE",
"types":[
"country",
"political"
]
}
],
"Caracas, Venezuela",
{
"bounds":{
"northeast":{
"lat":10.5401335,
"lng":-66.7179533
},
"southwest":{
"lat":10.39665,
"lng":-67.0627784
}
},
"location":{
"lat":10.4696404,
"lng":-66.8037185
},
"location_type":"APPROXIMATE",
"viewport":{
"northeast":{
"lat":10.5401335,
"lng":-66.7179533
},
"southwest":{
"lat":10.39665,
"lng":-67.0627784
}
}
},
"ChIJB0iCza1YKowRg4SZCq4u3ZM",
[
"locality",
"political"
],
{
"long_name":"Caracas",
"short_name":"CCS",
"types":[
"locality",
"political"
]
},
{
"long_name":"Libertador",
"short_name":"Libertador",
"types":[
"administrative_area_level_2",
"political"
]
},
{
"long_name":"Capital District",
"short_name":"Dto. Capital",
"types":[
"administrative_area_level_1",
"political"
]
},
{
"long_name":"Venezuela",
"short_name":"VE",
"types":[
"country",
"political"
]
},
"Caracas",
"CCS",
[
"locality",
"political"
],
"locality",
"political",
"Libertador",
"Libertador",
[
"administrative_area_level_2",
"political"
],
"administrative_area_level_2",
"political",
"Capital District",
"Dto. Capital",
[
"administrative_area_level_1",
"political"
],
"administrative_area_level_1",
"political",
"Venezuela",
"VE",
[
"country",
"political"
],
"country",
"political",
{
"northeast":{
"lat":10.5401335,
"lng":-66.7179533
},
"southwest":{
"lat":10.39665,
"lng":-67.0627784
}
},
{
"lat":10.4696404,
"lng":-66.8037185
},
"APPROXIMATE",
{
"northeast":{
"lat":10.5401335,
"lng":-66.7179533
},
"southwest":{
"lat":10.39665,
"lng":-67.0627784
}
},
{
"lat":10.5401335,
"lng":-66.7179533
},
{
"lat":10.39665,
"lng":-67.0627784
},
10.5401335,
-66.7179533,
10.39665,
-67.0627784,
10.4696404,
-66.8037185,
{
"lat":10.5401335,
"lng":-66.7179533
},
{
"lat":10.39665,
"lng":-67.0627784
},
10.5401335,
-66.7179533,
10.39665,
-67.0627784,
"locality",
"political",
[
{
"long_name":"Venezuela",
"short_name":"VE",
"types":[
"country",
"political"
]
}
],
"Venezuela",
{
"bounds":{
"northeast":{
"lat":12.4866941,
"lng":-59.805666
},
"southwest":{
"lat":0.647529,
"lng":-73.351558
}
},
"location":{
"lat":6.42375,
"lng":-66.58973
},
"location_type":"APPROXIMATE",
"viewport":{
"northeast":{
"lat":14.470409,
"lng":-59.80378
},
"southwest":{
"lat":-4.1438179,
"lng":-79.0255611
}
}
},
"ChIJAdjLNstTKIwR003VfFjyoNw",
[
"country",
"political"
],
{
"long_name":"Venezuela",
"short_name":"VE",
"types":[
"country",
"political"
]
},
"Venezuela",
"VE",
[
"country",
"political"
],
"country",
"political",
{
"northeast":{
"lat":12.4866941,
"lng":-59.805666
},
"southwest":{
"lat":0.647529,
"lng":-73.351558
}
},
{
"lat":6.42375,
"lng":-66.58973
},
"APPROXIMATE",
{
"northeast":{
"lat":14.470409,
"lng":-59.80378
},
"southwest":{
"lat":-4.1438179,
"lng":-79.0255611
}
},
{
"lat":12.4866941,
"lng":-59.805666
},
{
"lat":0.647529,
"lng":-73.351558
},
12.4866941,
-59.805666,
0.647529,
-73.351558,
6.42375,
-66.58973,
{
"lat":14.470409,
"lng":-59.80378
},
{
"lat":-4.1438179,
"lng":-79.0255611
},
14.470409,
-59.80378,
-4.1438179,
-79.0255611,
"country",
"political"
]
Upvotes: 1
Views: 577
Reputation: 1155
Okay, seems it's clear now. 'Messed up' response is the result of the application of JSONPath expression, result of which is the array, not the JSON Object. You can check some examples here: https://github.com/s3u/JSONPath/blob/master/test/test.examples.js
So, if you need just the status you can use this filter: "responsePath": "$.status"
. Otherwise, you can remove responsePath
completely and get the original JSON object.
Upvotes: 1