Related
I'm new in web development, I need your help & suggestion to make with easy ways vertical table in JSP or Javascript from the JSON data, like below image:
This is for table from database:
And here for the JSON data:
{
"_embedded" : {
"shipping" : [ {
"dayCd" : "1",
"shiftCd" : "1",
"qty" : "40",
"productName" : "Prod1",
"_links" : {
"self" : {
"href" : "http://127.0.0.1:8080/shipping/1001"
},
"shipping" : {
"href" : "http://127.0.0.1:8080/shipping/1001"
}
}
}, {
"dayCd" : "2",
"shiftCd" : "1",
"qty" : "40",
"productName" : "Prod1",
"_links" : {
"self" : {
"href" : "http://127.0.0.1:8080/shipping/1002"
},
"shipping" : {
"href" : "http://127.0.0.1:8080/shipping/1002"
}
}
}, {
"dayCd" : "3",
"shiftCd" : "1",
"qty" : "40",
"productName" : "Prod1",
"_links" : {
"self" : {
"href" : "http://127.0.0.1:8080/shipping/1003"
},
"shipping" : {
"href" : "http://127.0.0.1:8080/shipping/1003"
}
}
..........
I am executing this query :
{
"query" : {
"match" : {
"studyID" : {
"query" : 1,
"type" : "boolean"
}
}
},
"aggregations" : {
"25-34" : {
"date_range" : {
"field" : "timestamp",
"ranges" : [ {
"from" : "1992",
"to" : "1983"
} ],
"format" : "yyyy"
},
"aggregations" : {
"activityType" : {
"terms" : {
"field" : "activityType"
}
}
}
},
"84-*" : {
"date_range" : {
"field" : "timestamp",
"ranges" : [ {
"from" : "1933"
} ],
"format" : "yyyy"
},
"aggregations" : {
"activityType" : {
"terms" : {
"field" : "activityType"
}
}
}
},
"18-24" : {
"date_range" : {
"field" : "timestamp",
"ranges" : [ {
"from" : "1999",
"to" : "1993"
} ],
"format" : "yyyy"
},
"aggregations" : {
"activityType" : {
"terms" : {
"field" : "activityType"
}
}
}
},
"75-84" : {
"date_range" : {
"field" : "timestamp",
"ranges" : [ {
"from" : "1942",
"to" : "1933"
} ],
"format" : "yyyy"
},
"aggregations" : {
"activityType" : {
"terms" : {
"field" : "activityType"
}
}
}
},
"0-17" : {
"date_range" : {
"field" : "timestamp",
"ranges" : [ {
"from" : "2017",
"to" : "2000"
} ],
"format" : "yyyy"
},
"aggregations" : {
"activityType" : {
"terms" : {
"field" : "activityType"
}
}
}
},
"55-64" : {
"date_range" : {
"field" : "timestamp",
"ranges" : [ {
"from" : "1962",
"to" : "1953"
} ],
"format" : "yyyy"
},
"aggregations" : {
"activityType" : {
"terms" : {
"field" : "activityType"
}
}
}
},
"65-74" : {
"date_range" : {
"field" : "timestamp",
"ranges" : [ {
"from" : "1952",
"to" : "1943"
} ],
"format" : "yyyy"
},
"aggregations" : {
"activityType" : {
"terms" : {
"field" : "activityType"
}
}
}
},
"35-44" : {
"date_range" : {
"field" : "timestamp",
"ranges" : [ {
"from" : "1982",
"to" : "1973"
} ],
"format" : "yyyy"
},
"aggregations" : {
"activityType" : {
"terms" : {
"field" : "activityType"
}
}
}
},
"45-54" : {
"date_range" : {
"field" : "timestamp",
"ranges" : [ {
"from" : "1972",
"to" : "1963"
} ],
"format" : "yyyy"
},
"aggregations" : {
"activityType" : {
"terms" : {
"field" : "activityType"
}
}
}
}
}
}
Where I just want to aggregation activity based on date ranges and then sub aggregate those ranges by activity type but Elastic search is giving me this exception :
{
"error": {
"root_cause": [
{
"type": "aggregation_execution_exception",
"reason": "Invalid number format [yyyy#]"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "study",
"node": "MWkXAAOCSYuM-ubdkulNnw",
"reason": {
"type": "aggregation_execution_exception",
"reason": "Invalid number format [yyyy#]"
}
}
]
},
"status": 500
}
Any Ideas what am I missing?
The format parameter is to specify in which format the dates should be returned in the response, not in which format they are specified in the request. So depending on the date format of the timestamp field you have specified in your mapping type, your request needs to contain full-fledge dates, like this:
"25-34" : {
"date_range" : {
"field" : "timestamp",
"ranges" : [ {
"from" : "1992-01-01T00:00:00.000Z",
"to" : "1983-12-31T23:59.59.999Z"
} ],
"format" : "yyyy"
},
"aggregations" : {
"activityType" : {
"terms" : {
"field" : "activityType"
}
}
}
},
I am using the below to map a json response to a Map
Map<String, Object> apiResponse = restTemplate.postForObject("https://maps.googleapis.com/maps/api/geocode/json?address="+defaultLocation+"&key="+API_KEY, httpEntity, Map.class, Collections.EMPTY_MAP);
I can use the below to output the entire JSON to a string
String jsonResponse = apiResponse.get("results").toString();
However, what I want to get is a nested value which is results->geometry->location
I have tried a number of solution with JSONArrays, JSONObjects, Substring but can't get them to work.
Response JSON:
{
"results" : [
{
"address_components" : [
{
"long_name" : "Auckland",
"short_name" : "Auckland",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Auckland",
"short_name" : "Auckland",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "Auckland",
"short_name" : "Auckland",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "New Zealand",
"short_name" : "NZ",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "Auckland, New Zealand",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : -36.660571,
"lng" : 175.287137
},
"southwest" : {
"lat" : -37.065475,
"lng" : 174.4438016
}
},
"location" : {
"lat" : -36.8484597,
"lng" : 174.7633315
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : -36.660571,
"lng" : 175.287137
},
"southwest" : {
"lat" : -37.065475,
"lng" : 174.4438016
}
}
},
"place_id" : "ChIJ--acWvtHDW0RF5miQ2HvAAU",
"types" : [ "locality", "political" ]
},
{
"address_components" : [
{
"long_name" : "Auckland",
"short_name" : "Auckland",
"types" : [ "political", "sublocality", "sublocality_level_1" ]
},
{
"long_name" : "Auckland",
"short_name" : "Auckland",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Auckland",
"short_name" : "Auckland",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "Auckland",
"short_name" : "Auckland",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "New Zealand",
"short_name" : "NZ",
"types" : [ "country", "political" ]
},
{
"long_name" : "1010",
"short_name" : "1010",
"types" : [ "postal_code" ]
}
],
"formatted_address" : "Auckland, 1010, New Zealand",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : -36.8364659,
"lng" : 174.7838398
},
"southwest" : {
"lat" : -36.8621041,
"lng" : 174.7503805
}
},
"location" : {
"lat" : -36.8484597,
"lng" : 174.7633315
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : -36.8364659,
"lng" : 174.7838398
},
"southwest" : {
"lat" : -36.8621041,
"lng" : 174.7503805
}
}
},
"place_id" : "ChIJuZqpSPtHDW0R4LOiQ2HvAAU",
"types" : [ "political", "sublocality", "sublocality_level_1" ]
}
],
"status" : "OK"
}
Any help would be greatly appreciated.
JSONObject obj=new JSONObject(jsonresult);
// get result array
JSONArray resultsarray= obj.getJSONArray("results");
for (int i=0;i<resultsarray.length(),i++){
// get Objects using index
JSONObject jsonobject= results.getJSONObject(i);
// get geometry object
JSONObject geometry= jsonobject.getJSONObject("geometry");
// get location object from geometry
JSONObject location= geometry.getJSONObject("location");
// get location values from location object
double lat = location.optDouble("lat",0.0);
double long = location.optDouble("lng",0.0);
}
About optDouble
public double optDouble(String key, double defaultValue) {
Get an optional double associated with a key, or the defaultValue if
there is no such key or if its value is not a number. If the value is
a string, an attempt will be made to evaluate it as a number.
Ideally, you would like to access the properties with the same native notation like you would do in JS. Something like this:
String url = "https://maps.googleapis.com/maps/api/geocode/json?address=" + address;
String responseStr = fetch(url);
JsonHelper response = JsonHelper.forString(responseStr);
String status = (String) response.getValue("status");
if(status != null && status.equals("OK")) {
lat = (Double) response.getValue("results[0].geometry.location.lat");
lng = (Double) response.getValue("results[0].geometry.location.lng");
}
The following JsonHelper class code (taken from jello-framework) lets you do exactly that.
package jello.common;
import java.util.List;
import com.google.gson.Gson;
import java.util.AbstractMap;
public class JsonHelper {
private Object json;
public JsonHelper(String jsonString) {
Gson g = new Gson();
json = g.fromJson(jsonString, Object.class);
}
public static JsonHelper forString(String jsonString) {
return new JsonHelper(jsonString);
}
#SuppressWarnings("unchecked")
public Object getValue(String path) {
Object value = json;
String [] elements = path.split("\\.");
for(String element : elements) {
String ename = element.split("\\[")[0];
if(AbstractMap.class.isAssignableFrom(value.getClass())) {
value = ( (AbstractMap<String, Object>) value).get(ename);
if(element.contains("[")) {
if(List.class.isAssignableFrom(value.getClass())) {
Integer index = Integer.valueOf(element.substring(element.indexOf("[")+1, element.indexOf("]")) );
value = ((List<Object>) value).get(index);
}
else {
return null;
}
}
}
else {
return null;
}
}
return value;
}
}
Use jackson api for parsing,it will be easy
ObjectMapper mapper = new ObjectMapper();
JsonNode node = mapper.readTree(json);
if(node.get("results").isArray()){
for(int i=0; i <= node.get("results").size()-1; i++){
System.out.println(node.get("results").get(i));
}
I used Gson api and was able to get the location. Try this :
Code::
Gson gson = new Gson();
String json = "your json";
JsonObject map = gson.fromJson(json, JsonObject.class); // to be replaced with your restTemplate call
JsonArray arr = map.getAsJsonArray("results");
for (Object j : arr) {
System.out.println(((JsonObject) j).get("geometry").getAsJsonObject().get("location"));
}
Console Output::
{"lat":-36.8484597,"lng":174.7633315}
{"lat":-36.8484597,"lng":174.7633315}
So ideally just get the response as a JsonObject instead of a Map and you will be able to read the location.
Here's my mapping
{
"app" : {
"mappings" : {
"patient" : {
"properties" : {
"LastName" : {
"type" : "string"
},
"consultations" : {
"type" : "nested",
"properties" : {
"deleted" : {
"type" : "boolean"
},
"diagnosis" : {
"type" : "string"
},
"documentDate" : {
"type" : "date",
"format" : "dateOptionalTime"
},
"firstName" : {
"type" : "string"
},
"lastName" : {
"type" : "string"
},
"middleName" : {
"type" : "string"
},
"prescriptions" : {
"type" : "string"
}
}
},
"firstName" : {
"type" : "string"
},
"gender" : {
"type" : "string"
},
"id" : {
"type" : "string",
"index" : "not_analyzed"
},
"lastName" : {
"type" : "string"
},
"middleName" : {
"type" : "string"
},
"owner" : {
"type" : "string",
"index" : "not_analyzed"
},
"patientPin" : {
"type" : "string"
}
}
}
}
}
}
Then let's say I have this data
{
"id":"21",
"firstName":"Scrappy",
"patientPin":"2012010000000021",
"middleName":"D",
"consultations":[
{
"id":null,
"prescriptions":[
"GADOTERIC Acid DOTAREM"
],
"diagnosis":[
"Kawasaki's Disease",
"Alcohol Intoxication"
],
"documentDate":"2014-07-31T13:19:00.000+08:00",
"deleted":false,
"lastName":"Doo",
"firstName":"Scrappy",
"middleName":"D"
}
],
"owner":"TENANT1",
"gender":"FEMALE",
"lastName":"Doo"
}
{
"id":"100066",
"firstName":"Kyel ",
"patientPin":"201408000001",
"middleName":"John ",
"consultations":[
{
"id":null,
"prescriptions":[
],
"diagnosis":[
"headache"
],
"documentDate":"2014-08-05T10:10:00.000+08:00",
"deleted":false,
"lastName":"David",
"firstName":"Mika",
"middleName":"John "
}
],
"owner":"TENANT1",
"gender":"MALE",
"lastName":"David"
}
How do I query patients that has consultations that has a "headache" OR "Alcohol Intoxication"?
For your result I am suggesting you to use filter.
You can achieve this using,
For or, terms filter match document with any of value provided (which means does or for values)
client.prepareSearch("app").setTypes("patient").setPostFilter(
FilterBuilders.termsFilter("consultations.diagnosis","headache","Alcohol Intoxication")
);
For and,
client.prepareSearch("app").setTypes("patient").setPostFilter(
FilterBuilders.andFilter(
FilterBuilders.termsFilter("consultations.diagnosis","headache"),
FilterBuilders.termsFilter("consultations.diagnosis","Alcohol Intoxication")
)
);
For this, Any value you want to filter should be index : not_analyzed .
try learning elasticsearch.
This is my code for getting response from Geo-coder:
public class Snippet {
private GeoCodeResponse getAddressFromLatLng(double lattitute,
double longtitute) throws ClientProtocolException, IOException {
String latitude = String.valueOf(lattitute);
String longitude = String.valueOf(longtitute);
String URL = "http://maps.google.com/maps/api/geocode/json?latlng="
+ latitude + "," + longitude + "&sensor=true";
RestTemplate restTemplate = new RestTemplate();
ObjectMapper mapper = new ObjectMapper();
String forObject = restTemplate.getForObject(URL, String.class);
GeoCodeResponse geoCodeResponse = mapper.readValue(forObject,
GeoCodeResponse.class);
System.out.println(forObject);
return geoCodeResponse;
}
public static void main(String[] args) throws ClientProtocolException,
IOException {
GeoCodeResponse geoCoderResponse = new TrackServiceImpl()
.getAddressFromLatLng(17.42560, 78.548339);
if (geoCoderResponse.getStatus().equals("OK")) {
List<Results> listOfResults = geoCoderResponse.getResults();
for (Results result : listOfResults) {
// get Results Object
Iterator<Results> results = listOfResults.iterator();
while (results.hasNext()) {
result = results.next();
System.out.println(result.getFormatted_address());
// get Address Object
Collection<AddressComponent> addresscomponents = result
.getAddress_components();
Iterator<AddressComponent> addresscomponentsIterator = addresscomponents
.iterator();
while (addresscomponentsIterator.hasNext()) {
AddressComponent addressComponent = addresscomponentsIterator
.next();
System.out.println(addressComponent.getLong_name());
System.out.println(addressComponent.getShort_name());
}
// get Geometry Object
Geometry geometry = result.getGeometry();
System.out.println(geometry.getLocation_type());
// get Location Object
Location location = geometry.getLocation();
System.out.println(location.getLat());
System.out.println(location.getLng());
}
break;
}
}
}
private GeoCodeResponse getAddressFromLatLng(double lattitute,
double longtitute) throws ClientProtocolException, IOException {
String latitude = String.valueOf(lattitute);
String longitude = String.valueOf(longtitute);
String URL = "http://maps.google.com/maps/api/geocode/json?latlng="
+ latitude + "," + longitude + "&sensor=true";
RestTemplate restTemplate = new RestTemplate();
ObjectMapper mapper = new ObjectMapper();
String forObject = restTemplate.getForObject(URL, String.class);
GeoCodeResponse geoCodeResponse = mapper.readValue(forObject,
GeoCodeResponse.class);
System.out.println(forObject);
return geoCodeResponse;
}
}
This is the geo coder response:
{
"results" : [
{
"address_components" : [
{
"long_name" : "4-1-91/3",
"short_name" : "4-1-91/3",
"types" : []
},
{
"long_name" : "Nacharam Mallapur Road",
"short_name" : "Nacharam Mallapur Road",
"types" : [ "route" ]
},
{
"long_name" : "Bhavani Nagar",
"short_name" : "Bhavani Nagar",
"types" : [ "sublocality", "political" ]
},
{
"long_name" : "Tarnaka",
"short_name" : "Tarnaka",
"types" : [ "sublocality", "political" ]
},
{
"long_name" : "Secunderabad",
"short_name" : "SC",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Ranga Reddy",
"short_name" : "R.R. District",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "Andhra Pradesh",
"short_name" : "AP",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "India",
"short_name" : "IN",
"types" : [ "country", "political" ]
},
{
"long_name" : "500076",
"short_name" : "500076",
"types" : [ "postal_code" ]
}
],
"formatted_address" : "4-1-91/3, Nacharam Mallapur Road, Bhavani Nagar, Tarnaka, Secunderabad, Andhra Pradesh 500076, India",
"geometry" : {
"location" : {
"lat" : 17.4251743,
"lng" : 78.5480111
},
"location_type" : "ROOFTOP",
"viewport" : {
"northeast" : {
"lat" : 17.4265232802915,
"lng" : 78.54936008029151
},
"southwest" : {
"lat" : 17.4238253197085,
"lng" : 78.54666211970849
}
}
},
"types" : [ "street_address" ]
},
{
"address_components" : [
{
"long_name" : "Bhavani Nagar",
"short_name" : "Bhavani Nagar",
"types" : [ "sublocality", "political" ]
},
{
"long_name" : "Tarnaka",
"short_name" : "Tarnaka",
"types" : [ "sublocality", "political" ]
},
{
"long_name" : "Secunderabad",
"short_name" : "SC",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Ranga Reddy",
"short_name" : "R.R. District",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "Andhra Pradesh",
"short_name" : "AP",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "India",
"short_name" : "IN",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "Bhavani Nagar, Tarnaka, Secunderabad, Andhra Pradesh, India",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 17.4276068,
"lng" : 78.550246
},
"southwest" : {
"lat" : 17.4249009,
"lng" : 78.54588509999999
}
},
"location" : {
"lat" : 17.4261285,
"lng" : 78.5479845
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 17.4276068,
"lng" : 78.550246
},
"southwest" : {
"lat" : 17.4249009,
"lng" : 78.54588509999999
}
}
},
"types" : [ "sublocality", "political" ]
},
{
"address_components" : [
{
"long_name" : "500076",
"short_name" : "500076",
"types" : [ "postal_code" ]
},
{
"long_name" : "Andhra Pradesh",
"short_name" : "AP",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "India",
"short_name" : "IN",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "Andhra Pradesh 500076, India",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 17.4503108,
"lng" : 78.59751469999999
},
"southwest" : {
"lat" : 17.4199893,
"lng" : 78.5419289
}
},
"location" : {
"lat" : 17.4381342,
"lng" : 78.56040689999999
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 17.4503108,
"lng" : 78.59751469999999
},
"southwest" : {
"lat" : 17.4199893,
"lng" : 78.5419289
}
}
},
"types" : [ "postal_code" ]
},
{
"address_components" : [
{
"long_name" : "Hyderabad",
"short_name" : "Hyderabad",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "Andhra Pradesh",
"short_name" : "AP",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "India",
"short_name" : "IN",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "Hyderabad, Andhra Pradesh, India",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 17.4823267,
"lng" : 78.5604858
},
"southwest" : {
"lat" : 17.3486722,
"lng" : 78.4018707
}
},
"location" : {
"lat" : 17.385044,
"lng" : 78.486671
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 17.4823267,
"lng" : 78.5604858
},
"southwest" : {
"lat" : 17.3486722,
"lng" : 78.4018707
}
}
},
"types" : [ "administrative_area_level_2", "political" ]
},
{
"address_components" : [
{
"long_name" : "Secunderabad",
"short_name" : "SC",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Hyderabad",
"short_name" : "Hyderabad",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "Andhra Pradesh",
"short_name" : "AP",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "India",
"short_name" : "IN",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "Secunderabad, Andhra Pradesh, India",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 17.6393052,
"lng" : 78.64442819999999
},
"southwest" : {
"lat" : 17.4124778,
"lng" : 78.47253499999999
}
},
"location" : {
"lat" : 17.4399295,
"lng" : 78.4982741
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 17.6393052,
"lng" : 78.64442819999999
},
"southwest" : {
"lat" : 17.4124778,
"lng" : 78.47253499999999
}
}
},
"types" : [ "locality", "political" ]
},
{
"address_components" : [
{
"long_name" : "Ranga Reddy",
"short_name" : "R.R. District",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "Andhra Pradesh",
"short_name" : "AP",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "India",
"short_name" : "IN",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "Ranga Reddy, Andhra Pradesh, India",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 17.701268,
"lng" : 78.8475038
},
"southwest" : {
"lat" : 16.8492337,
"lng" : 77.3753358
}
},
"location" : {
"lat" : 17.2031945,
"lng" : 77.8367282
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 17.701268,
"lng" : 78.8475038
},
"southwest" : {
"lat" : 16.8492337,
"lng" : 77.3753358
}
}
},
"types" : [ "administrative_area_level_2", "political" ]
},
{
"address_components" : [
{
"long_name" : "Andhra Pradesh",
"short_name" : "AP",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "India",
"short_name" : "IN",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "Andhra Pradesh, India",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 19.916715,
"lng" : 84.80412939999999
},
"southwest" : {
"lat" : 12.596836,
"lng" : 76.749786
}
},
"location" : {
"lat" : 17.0477624,
"lng" : 80.0981869
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 19.916715,
"lng" : 84.80412939999999
},
"southwest" : {
"lat" : 12.596836,
"lng" : 76.749786
}
}
},
"types" : [ "administrative_area_level_1", "political" ]
},
{
"address_components" : [
{
"long_name" : "India",
"short_name" : "IN",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "India",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 35.5044752,
"lng" : 97.395555
},
"southwest" : {
"lat" : 6.747138899999999,
"lng" : 68.1623859
}
},
"location" : {
"lat" : 20.593684,
"lng" : 78.96288
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 35.5044752,
"lng" : 97.395555
},
"southwest" : {
"lat" : 6.747138899999999,
"lng" : 68.1627956
}
}
},
"types" : [ "country", "political" ]
}
],
"status" : "OK"
}
Here my question is how to get these from below objects ?
> address components:
"long_name" : "Secunderabad",
"short_name" : "SC",
"long_name" : "Andhra Pradesh",
"short_name" : "AP",
"long_name" : "Andhra Pradesh",
"short_name" : "AP",
> location :
"lat" : 17.4251743,
"lng" : 78.5480111**
Please help me, I unable to get this formatted address.
Thanks in advance.