Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用GSON处理json的Java片段_Java_Json_Gson - Fatal编程技术网

用GSON处理json的Java片段

用GSON处理json的Java片段,java,json,gson,Java,Json,Gson,我有一个JSON响应: { "results" : [ { "address_components" : [ { "long_name" : "3", "short_name" : "3", "types" : [ "street_number" ] }, { "

我有一个JSON响应:

    {
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "3",
               "short_name" : "3",
               "types" : [ "street_number" ]
            },
            {
               "long_name" : "1033",
               "short_name" : "1033",
               "types" : []
            },
            {
               "long_name" : "K osmidomkům",
               "short_name" : "K osmidomkům",
               "types" : [ "route" ]
            },
            {
               "long_name" : "Praha-Suchdol",
               "short_name" : "Praha-Suchdol",
               "types" : [ "sublocality", "political" ]
            },
            {
               "long_name" : "Praha",
               "short_name" : "Praha",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Hlavní město Praha",
               "short_name" : "Hlavní město Praha",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Hlavní město Praha",
               "short_name" : "Hlavní město Praha",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Česká republika",
               "short_name" : "CZ",
               "types" : [ "country", "political" ]
            },
            {
               "long_name" : "165 00",
               "short_name" : "165 00",
               "types" : [ "postal_code" ]
            },
            {
               "long_name" : "Praha 620",
               "short_name" : "Praha 620",
               "types" : [ "postal_town" ]
            }
         ],
         "formatted_address" : "K osmidomkům 1033/3, 165 00 Praha-Praha-Suchdol, Česká republika",
         "geometry" : {
            "location" : {
               "lat" : 50.13670170,
               "lng" : 14.36865280
            },
            "location_type" : "ROOFTOP",
            "viewport" : {
               "northeast" : {
                  "lat" : 50.13805068029150,
                  "lng" : 14.37000178029150
               },
               "southwest" : {
                  "lat" : 50.13535271970850,
                  "lng" : 14.36730381970850
               }
            }
         },
         "types" : [ "street_address" ]
      }
   ],
   "status" : "OK"
}
现在我需要通过GSON处理JSON,但我只需要“geometry”中的一节。我需要位置(纬度,液化天然气)。如何将这段json绑定到POJO?我的意思是这样的

public class GoogleMapLocation
{
    @SerializedName("lat")
    private double latitude;

    @SerializedName("lng")
    private double longitude;

    public double getLatitude()
    {
        return latitude;
    }

    public void setLatitude(final double latitude)
    {
        this.latitude = latitude;
    }

    public double getLongitude()
    {
        return longitude;
    }

    public void setLongitude(final double longitude)
    {
        this.longitude = longitude;
    }
}
然后

GoogleMapLocation gml = gson.fromJson(jsonReader, GoogleMapLocation.class);
这应该是可行的(为了清晰起见省略了getter、setter等,而不是防错的):

公共类GoogleMapLocation{
列出结果;
字符串状态;
}
公开课成绩{
@SerializedName(“地址\组件”)
私人名单


编辑:请注意,某些字段也可以声明为枚举(
状态
,…)

使用RC的代码生成完整的工作示例

测试
类,以获取
几何体
内容

package com.yourcomp.test2;

import com.google.gson.Gson;

public class Test {


    public static void main(String[] args) {
        String test = "{" + 
        "   \"results\" : [" + 
        "      {" + 
        "         \"address_components\" : [" + 
        "            {" + 
        "               \"long_name\" : \"3\"," + 
        "               \"short_name\" : \"3\"," + 
        "               \"types\" : [ \"street_number\" ]" + 
        "            }," + 
        "            {" + 
        "               \"long_name\" : \"1033\"," + 
        "               \"short_name\" : \"1033\"," + 
        "               \"types\" : []" + 
        "            }," + 
        "            {" + 
        "               \"long_name\" : \"K osmidomkum\"," + 
        "               \"short_name\" : \"K osmidomkum\"," + 
        "               \"types\" : [ \"route\" ]" + 
        "            }," + 
        "            {" + 
        "               \"long_name\" : \"Praha-Suchdol\"," + 
        "               \"short_name\" : \"Praha-Suchdol\"," + 
        "               \"types\" : [ \"sublocality\", \"political\" ]" + 
        "            }," + 
        "            {" + 
        "               \"long_name\" : \"Praha\"," + 
        "               \"short_name\" : \"Praha\"," + 
        "               \"types\" : [ \"locality\", \"political\" ]" + 
        "            }," + 
        "            {" + 
        "               \"long_name\" : \"Hlavní mesto Praha\"," + 
        "               \"short_name\" : \"Hlavní mesto Praha\"," + 
        "               \"types\" : [ \"administrative_area_level_2\", \"political\" ]" + 
        "            }," + 
        "            {" + 
        "               \"long_name\" : \"Hlavní mesto Praha\"," + 
        "               \"short_name\" : \"Hlavní mesto Praha\"," + 
        "               \"types\" : [ \"administrative_area_level_1\", \"political\" ]" + 
        "            }," + 
        "            {" + 
        "               \"long_name\" : \"Ceská republika\"," + 
        "               \"short_name\" : \"CZ\"," + 
        "               \"types\" : [ \"country\", \"political\" ]" + 
        "            }," + 
        "            {" + 
        "               \"long_name\" : \"165 00\"," + 
        "               \"short_name\" : \"165 00\"," + 
        "               \"types\" : [ \"postal_code\" ]" + 
        "            }," + 
        "            {" + 
        "               \"long_name\" : \"Praha 620\"," + 
        "               \"short_name\" : \"Praha 620\"," + 
        "               \"types\" : [ \"postal_town\" ]" + 
        "            }" + 
        "         ]," + 
        "         \"formatted_address\" : \"K osmidomkum 1033/3, 165 00 Praha-Praha-Suchdol, Ceská republika\"," + 
        "         \"geometry\" : {" + 
        "            \"location\" : {" + 
        "               \"lat\" : 50.13670170," + 
        "               \"lng\" : 14.36865280" + 
        "            }," + 
        "            \"location_type\" : \"ROOFTOP\"," + 
        "            \"viewport\" : {" + 
        "               \"northeast\" : {" + 
        "                  \"lat\" : 50.13805068029150," + 
        "                  \"lng\" : 14.37000178029150" + 
        "               }," + 
        "               \"southwest\" : {" + 
        "                  \"lat\" : 50.13535271970850," + 
        "                  \"lng\" : 14.36730381970850" + 
        "               }" + 
        "            }" + 
        "         }," + 
        "         \"types\" : [ \"street_address\" ]" + 
        "      }" + 
        "   ]," + 
        "   \"status\" : \"OK\"" + 
        "}";
        GoogleMapLocation res = new Gson().fromJson(test, GoogleMapLocation.class);
        System.out.println(res);

        Geometry geometry = res.getResults().get(0).getGeometry();
        System.out.println(geometry);
    }

}
GoogleMapLocation

package com.yourcomp.test2;

import java.util.List;

import com.google.gson.annotations.SerializedName;

public class GoogleMapLocation {
    List<Result> results;

    String status;

    /**
     * Gets the results.
     * 
     * @return <tt> the results.</tt>
     */
    public List<Result> getResults() {
        return results;
    }

    /**
     * Sets the results.
     * 
     * @param results
     *            <tt> the results to set.</tt>
     */
    public void setResults(List<Result> results) {
        this.results = results;
    }

    /**
     * Gets the status.
     * 
     * @return <tt> the status.</tt>
     */
    public String getStatus() {
        return status;
    }

    /**
     * Sets the status.
     * 
     * @param status
     *            <tt> the status to set.</tt>
     */
    public void setStatus(String status) {
        this.status = status;
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        return "GoogleMapLocation [results=" + results + ", status=" + status
                + "]";
    }

}

class Result {
    @SerializedName("address_components")
    private List<AddressComponents> addressComponents;

    /**
     * Gets the addressComponents.
     * 
     * @return <tt> the addressComponents.</tt>
     */
    public List<AddressComponents> getAddressComponents() {
        return addressComponents;
    }

    /**
     * Sets the addressComponents.
     * 
     * @param addressComponents
     *            <tt> the addressComponents to set.</tt>
     */
    public void setAddressComponents(List<AddressComponents> addressComponents) {
        this.addressComponents = addressComponents;
    }

    /**
     * Gets the formattedAddress.
     * 
     * @return <tt> the formattedAddress.</tt>
     */
    public String getFormattedAddress() {
        return formattedAddress;
    }

    /**
     * Sets the formattedAddress.
     * 
     * @param formattedAddress
     *            <tt> the formattedAddress to set.</tt>
     */
    public void setFormattedAddress(String formattedAddress) {
        this.formattedAddress = formattedAddress;
    }

    /**
     * Gets the geometry.
     * 
     * @return <tt> the geometry.</tt>
     */
    public Geometry getGeometry() {
        return geometry;
    }

    /**
     * Sets the geometry.
     * 
     * @param geometry
     *            <tt> the geometry to set.</tt>
     */
    public void setGeometry(Geometry geometry) {
        this.geometry = geometry;
    }

    /**
     * Gets the partialMatch.
     * 
     * @return <tt> the partialMatch.</tt>
     */
    public String getPartialMatch() {
        return partialMatch;
    }

    /**
     * Sets the partialMatch.
     * 
     * @param partialMatch
     *            <tt> the partialMatch to set.</tt>
     */
    public void setPartialMatch(String partialMatch) {
        this.partialMatch = partialMatch;
    }

    /**
     * Gets the types.
     * 
     * @return <tt> the types.</tt>
     */
    public List<String> getTypes() {
        return types;
    }

    /**
     * Sets the types.
     * 
     * @param types
     *            <tt> the types to set.</tt>
     */
    public void setTypes(List<String> types) {
        this.types = types;
    }

    @SerializedName("formatted_address")
    private String formattedAddress;

    private Geometry geometry;

    @SerializedName("partial_match")
    private String partialMatch; // not sure of the type

    private List<String> types;

    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        return "Result [addressComponents=" + addressComponents
                + ", formattedAddress=" + formattedAddress + ", geometry="
                + geometry + ", partialMatch=" + partialMatch + ", types="
                + types + "]";
    }
}

class AddressComponents {
    private String long_name;
    private String short_name;
    private List<String> types;

    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        return "AddressComponents [long_name=" + long_name + ", short_name="
                + short_name + ", types=" + types + "]";
    }

    /**
     * Gets the long_name.
     * 
     * @return <tt> the long_name.</tt>
     */
    public String getLong_name() {
        return long_name;
    }

    /**
     * Sets the long_name.
     * 
     * @param long_name
     *            <tt> the long_name to set.</tt>
     */
    public void setLong_name(String long_name) {
        this.long_name = long_name;
    }

    /**
     * Gets the short_name.
     * 
     * @return <tt> the short_name.</tt>
     */
    public String getShort_name() {
        return short_name;
    }

    /**
     * Sets the short_name.
     * 
     * @param short_name
     *            <tt> the short_name to set.</tt>
     */
    public void setShort_name(String short_name) {
        this.short_name = short_name;
    }

    /**
     * Gets the types.
     * 
     * @return <tt> the types.</tt>
     */
    public List<String> getTypes() {
        return types;
    }

    /**
     * Sets the types.
     * 
     * @param types
     *            <tt> the types to set.</tt>
     */
    public void setTypes(List<String> types) {
        this.types = types;
    }

}

class Geometry {
    LatLng location;

    Viewport viewport;

    Viewport bounds;

    @SerializedName("location_type")
    String locationType;

    /**
     * Gets the location.
     * 
     * @return <tt> the location.</tt>
     */
    public LatLng getLocation() {
        return location;
    }

    /**
     * Sets the location.
     * 
     * @param location
     *            <tt> the location to set.</tt>
     */
    public void setLocation(LatLng location) {
        this.location = location;
    }

    /**
     * Gets the viewport.
     * 
     * @return <tt> the viewport.</tt>
     */
    public Viewport getViewport() {
        return viewport;
    }

    /**
     * Sets the viewport.
     * 
     * @param viewport
     *            <tt> the viewport to set.</tt>
     */
    public void setViewport(Viewport viewport) {
        this.viewport = viewport;
    }

    /**
     * Gets the bounds.
     * 
     * @return <tt> the bounds.</tt>
     */
    public Viewport getBounds() {
        return bounds;
    }

    /**
     * Sets the bounds.
     * 
     * @param bounds
     *            <tt> the bounds to set.</tt>
     */
    public void setBounds(Viewport bounds) {
        this.bounds = bounds;
    }

    /**
     * Gets the locationType.
     * 
     * @return <tt> the locationType.</tt>
     */
    public String getLocationType() {
        return locationType;
    }

    /**
     * Sets the locationType.
     * 
     * @param locationType
     *            <tt> the locationType to set.</tt>
     */
    public void setLocationType(String locationType) {
        this.locationType = locationType;
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        return "Geometry [location=" + location + ", viewport=" + viewport
                + ", bounds=" + bounds + ", locationType=" + locationType + "]";
    }

}

class LatLng {
    @SerializedName("lat")
    private double latitude;

    @SerializedName("lng")
    private double longitude;

    /**
     * Gets the latitude.
     * 
     * @return <tt> the latitude.</tt>
     */
    public double getLatitude() {
        return latitude;
    }

    /**
     * Sets the latitude.
     * 
     * @param latitude
     *            <tt> the latitude to set.</tt>
     */
    public void setLatitude(double latitude) {
        this.latitude = latitude;
    }

    /**
     * Gets the longitude.
     * 
     * @return <tt> the longitude.</tt>
     */
    public double getLongitude() {
        return longitude;
    }

    /**
     * Sets the longitude.
     * 
     * @param longitude
     *            <tt> the longitude to set.</tt>
     */
    public void setLongitude(double longitude) {
        this.longitude = longitude;
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        return "LatLng [latitude=" + latitude + ", longitude=" + longitude
                + "]";
    }

}

class Viewport {
    private LatLng northeast;

    /**
     * Gets the northeast.
     * 
     * @return <tt> the northeast.</tt>
     */
    public LatLng getNortheast() {
        return northeast;
    }

    /**
     * Sets the northeast.
     * 
     * @param northeast
     *            <tt> the northeast to set.</tt>
     */
    public void setNortheast(LatLng northeast) {
        this.northeast = northeast;
    }

    /**
     * Gets the southwest.
     * 
     * @return <tt> the southwest.</tt>
     */
    public LatLng getSouthwest() {
        return southwest;
    }

    /**
     * Sets the southwest.
     * 
     * @param southwest
     *            <tt> the southwest to set.</tt>
     */
    public void setSouthwest(LatLng southwest) {
        this.southwest = southwest;
    }

    private LatLng southwest;

    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        return "Viewport [northeast=" + northeast + ", southwest=" + southwest
                + "]";
    }

}
package com.yourcomp.test2;
导入java.util.List;
导入com.google.gson.annotations.SerializedName;
公共类GoogleMapLocation{
列出结果;
字符串状态;
/**
*获取结果。
* 
*@返回结果。
*/
公共列表getResults(){
返回结果;
}
/**
*设置结果。
* 
*@param结果
*结果有待确定。
*/
公共void setResults(列出结果){
这个结果=结果;
}
/**
*获取状态。
* 
*@返回状态。
*/
公共字符串getStatus(){
返回状态;
}
/**
*设置状态。
* 
*@param状态
*要设置的状态。
*/
公共无效设置状态(字符串状态){
这个状态=状态;
}
/*
*(非Javadoc)
* 
*@see java.lang.Object#toString()
*/
@凌驾
公共字符串toString(){
返回“GoogleMapLocation[results=“+results+”,status=“+status
+ "]";
}
}
班级成绩{
@SerializedName(“地址\组件”)
私有列表组件;
/**
*获取addressComponents。
* 
*@返回addressComponents。
*/
公共列表getAddressComponents(){
返回地址组件;
}
/**
*设置组件的地址。
* 
*@param-addressComponents
*要设置的地址组件。
*/
public void setAddressComponents(列出addressComponents){
this.addressComponents=addressComponents;
}
/**
*获取格式化的地址。
* 
*@返回格式化的地址。
*/
公共字符串getFormattedAddress(){
返回格式化的地址;
}
/**
*设置格式化的地址。
* 
*@param格式化地址
*要设置的格式化地址。
*/
公共void setFormattedAddress(字符串formattedAddress){
this.formattedAddress=formattedAddress;
}
/**
*获取几何体。
* 
*@返回几何体。
*/
公共几何体getGeometry(){
返回几何;
}
/**
*设置几何图形。
* 
*@param几何体
*要设置的几何图形。
*/
公共空心集几何图形(几何图形){
这个几何=几何;
}
/**
*获取partialMatch。
* 
*@返回游击队比赛。
*/
公共字符串getPartialMatch(){
返回部分匹配;
}
/**
*设置partialMatch。
* 
*@param partialMatch
*游击队比赛开始了。
*/
public void setPartialMatch(字符串partialMatch){
this.partialMatch=partialMatch;
}
/**
*获取类型。
* 
*@返回类型。
*/
公共列表getTypes(){
返回类型;
}
/**
*设置类型。
* 
*@param类型
*要设置的类型。
*/
公共void集合类型(列表类型){
this.types=类型;
}
@SerializedName(“格式化的地址”)
私有字符串格式化地址;
私人几何;
@SerializedName(“部分匹配”)
私有字符串partialMatch;//不确定类型
私有列表类型;
/*
*(非Javadoc)
* 
*@see java.lang.Object#toString()
*/
@凌驾
公共字符串toString(){
return“Result[addressComponents=“+addressComponents
+“,formattedAddress=“+formattedAddress+”,几何图形=”
+几何图形+”,partialMatch=“+partialMatch+”,类型=”
+类型+“]”;
}
}
类地址组件{
私有字符串长名称;
私有字符串短_名称;
私有列表类型;
/*
*(非Javadoc)
* 
*@see java.lang.Object#toString()
*/
@凌驾
公共字符串toString(){
返回“AddressComponents[long_name=“+long_name+”,short_name=”
+短_name+”,types=“+types+”];
}
/**
*获取长名称。
* 
*@返回长_名称。
*/
公共字符串getLong_name(){
返回long_名称;
}
/**
*设置长名称。
* 
*@param long_name
*要设置的长名称。
*/
public void setLong\u name(字符串long\u name){
this.long\u name=long\u name;
}
/**
*获取短名称。
* 
*@返回短名称。
*/
公共字符串getShort_name(){
返回短名称;
}
/**
*设置短名称。
* 
*@param short_name
*要设置的短名称。
*/
public void setShort_name(字符串short_name){
this.short\u name=short\u name;
}
/**
*获取类型。
* 
*@返回类型。
*/
公共列表getTypes(){
返回类型;
}
/**
*设置类型。
* 
*@param类型
*要设置的类型。
*/
公共void集合类型(列表类型){
this.types=类型;
}
}
类几何{
定位;
视口;
视口边界;
@硒
package com.yourcomp.test2;

import java.util.List;

import com.google.gson.annotations.SerializedName;

public class GoogleMapLocation {
    List<Result> results;

    String status;

    /**
     * Gets the results.
     * 
     * @return <tt> the results.</tt>
     */
    public List<Result> getResults() {
        return results;
    }

    /**
     * Sets the results.
     * 
     * @param results
     *            <tt> the results to set.</tt>
     */
    public void setResults(List<Result> results) {
        this.results = results;
    }

    /**
     * Gets the status.
     * 
     * @return <tt> the status.</tt>
     */
    public String getStatus() {
        return status;
    }

    /**
     * Sets the status.
     * 
     * @param status
     *            <tt> the status to set.</tt>
     */
    public void setStatus(String status) {
        this.status = status;
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        return "GoogleMapLocation [results=" + results + ", status=" + status
                + "]";
    }

}

class Result {
    @SerializedName("address_components")
    private List<AddressComponents> addressComponents;

    /**
     * Gets the addressComponents.
     * 
     * @return <tt> the addressComponents.</tt>
     */
    public List<AddressComponents> getAddressComponents() {
        return addressComponents;
    }

    /**
     * Sets the addressComponents.
     * 
     * @param addressComponents
     *            <tt> the addressComponents to set.</tt>
     */
    public void setAddressComponents(List<AddressComponents> addressComponents) {
        this.addressComponents = addressComponents;
    }

    /**
     * Gets the formattedAddress.
     * 
     * @return <tt> the formattedAddress.</tt>
     */
    public String getFormattedAddress() {
        return formattedAddress;
    }

    /**
     * Sets the formattedAddress.
     * 
     * @param formattedAddress
     *            <tt> the formattedAddress to set.</tt>
     */
    public void setFormattedAddress(String formattedAddress) {
        this.formattedAddress = formattedAddress;
    }

    /**
     * Gets the geometry.
     * 
     * @return <tt> the geometry.</tt>
     */
    public Geometry getGeometry() {
        return geometry;
    }

    /**
     * Sets the geometry.
     * 
     * @param geometry
     *            <tt> the geometry to set.</tt>
     */
    public void setGeometry(Geometry geometry) {
        this.geometry = geometry;
    }

    /**
     * Gets the partialMatch.
     * 
     * @return <tt> the partialMatch.</tt>
     */
    public String getPartialMatch() {
        return partialMatch;
    }

    /**
     * Sets the partialMatch.
     * 
     * @param partialMatch
     *            <tt> the partialMatch to set.</tt>
     */
    public void setPartialMatch(String partialMatch) {
        this.partialMatch = partialMatch;
    }

    /**
     * Gets the types.
     * 
     * @return <tt> the types.</tt>
     */
    public List<String> getTypes() {
        return types;
    }

    /**
     * Sets the types.
     * 
     * @param types
     *            <tt> the types to set.</tt>
     */
    public void setTypes(List<String> types) {
        this.types = types;
    }

    @SerializedName("formatted_address")
    private String formattedAddress;

    private Geometry geometry;

    @SerializedName("partial_match")
    private String partialMatch; // not sure of the type

    private List<String> types;

    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        return "Result [addressComponents=" + addressComponents
                + ", formattedAddress=" + formattedAddress + ", geometry="
                + geometry + ", partialMatch=" + partialMatch + ", types="
                + types + "]";
    }
}

class AddressComponents {
    private String long_name;
    private String short_name;
    private List<String> types;

    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        return "AddressComponents [long_name=" + long_name + ", short_name="
                + short_name + ", types=" + types + "]";
    }

    /**
     * Gets the long_name.
     * 
     * @return <tt> the long_name.</tt>
     */
    public String getLong_name() {
        return long_name;
    }

    /**
     * Sets the long_name.
     * 
     * @param long_name
     *            <tt> the long_name to set.</tt>
     */
    public void setLong_name(String long_name) {
        this.long_name = long_name;
    }

    /**
     * Gets the short_name.
     * 
     * @return <tt> the short_name.</tt>
     */
    public String getShort_name() {
        return short_name;
    }

    /**
     * Sets the short_name.
     * 
     * @param short_name
     *            <tt> the short_name to set.</tt>
     */
    public void setShort_name(String short_name) {
        this.short_name = short_name;
    }

    /**
     * Gets the types.
     * 
     * @return <tt> the types.</tt>
     */
    public List<String> getTypes() {
        return types;
    }

    /**
     * Sets the types.
     * 
     * @param types
     *            <tt> the types to set.</tt>
     */
    public void setTypes(List<String> types) {
        this.types = types;
    }

}

class Geometry {
    LatLng location;

    Viewport viewport;

    Viewport bounds;

    @SerializedName("location_type")
    String locationType;

    /**
     * Gets the location.
     * 
     * @return <tt> the location.</tt>
     */
    public LatLng getLocation() {
        return location;
    }

    /**
     * Sets the location.
     * 
     * @param location
     *            <tt> the location to set.</tt>
     */
    public void setLocation(LatLng location) {
        this.location = location;
    }

    /**
     * Gets the viewport.
     * 
     * @return <tt> the viewport.</tt>
     */
    public Viewport getViewport() {
        return viewport;
    }

    /**
     * Sets the viewport.
     * 
     * @param viewport
     *            <tt> the viewport to set.</tt>
     */
    public void setViewport(Viewport viewport) {
        this.viewport = viewport;
    }

    /**
     * Gets the bounds.
     * 
     * @return <tt> the bounds.</tt>
     */
    public Viewport getBounds() {
        return bounds;
    }

    /**
     * Sets the bounds.
     * 
     * @param bounds
     *            <tt> the bounds to set.</tt>
     */
    public void setBounds(Viewport bounds) {
        this.bounds = bounds;
    }

    /**
     * Gets the locationType.
     * 
     * @return <tt> the locationType.</tt>
     */
    public String getLocationType() {
        return locationType;
    }

    /**
     * Sets the locationType.
     * 
     * @param locationType
     *            <tt> the locationType to set.</tt>
     */
    public void setLocationType(String locationType) {
        this.locationType = locationType;
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        return "Geometry [location=" + location + ", viewport=" + viewport
                + ", bounds=" + bounds + ", locationType=" + locationType + "]";
    }

}

class LatLng {
    @SerializedName("lat")
    private double latitude;

    @SerializedName("lng")
    private double longitude;

    /**
     * Gets the latitude.
     * 
     * @return <tt> the latitude.</tt>
     */
    public double getLatitude() {
        return latitude;
    }

    /**
     * Sets the latitude.
     * 
     * @param latitude
     *            <tt> the latitude to set.</tt>
     */
    public void setLatitude(double latitude) {
        this.latitude = latitude;
    }

    /**
     * Gets the longitude.
     * 
     * @return <tt> the longitude.</tt>
     */
    public double getLongitude() {
        return longitude;
    }

    /**
     * Sets the longitude.
     * 
     * @param longitude
     *            <tt> the longitude to set.</tt>
     */
    public void setLongitude(double longitude) {
        this.longitude = longitude;
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        return "LatLng [latitude=" + latitude + ", longitude=" + longitude
                + "]";
    }

}

class Viewport {
    private LatLng northeast;

    /**
     * Gets the northeast.
     * 
     * @return <tt> the northeast.</tt>
     */
    public LatLng getNortheast() {
        return northeast;
    }

    /**
     * Sets the northeast.
     * 
     * @param northeast
     *            <tt> the northeast to set.</tt>
     */
    public void setNortheast(LatLng northeast) {
        this.northeast = northeast;
    }

    /**
     * Gets the southwest.
     * 
     * @return <tt> the southwest.</tt>
     */
    public LatLng getSouthwest() {
        return southwest;
    }

    /**
     * Sets the southwest.
     * 
     * @param southwest
     *            <tt> the southwest to set.</tt>
     */
    public void setSouthwest(LatLng southwest) {
        this.southwest = southwest;
    }

    private LatLng southwest;

    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        return "Viewport [northeast=" + northeast + ", southwest=" + southwest
                + "]";
    }

}