Java Google在jsonparser中放置review、arraylist

Java Google在jsonparser中放置review、arraylist,java,android,python,xml,json,Java,Android,Python,Xml,Json,我遇到了一个问题,所以我正在使用google places api 我不会在这里写完整的代码,因为它太大了。但每当我调用google api时,我都会得到这样的结果: { "html_attributions" : [], "result" : { "address_components" : [ { "long_name" : "48", "short_name" : "48",

我遇到了一个问题,所以我正在使用google places api

我不会在这里写完整的代码,因为它太大了。但每当我调用google api时,我都会得到这样的结果:

{
   "html_attributions" : [],
   "result" : {
      "address_components" : [
         {
            "long_name" : "48",
            "short_name" : "48",
            "types" : [ "street_number" ]
         },
         {
            "long_name" : "Pirrama Road",
            "short_name" : "Pirrama Road",
            "types" : [ "route" ]
         },
         {
            "long_name" : "Pyrmont",
            "short_name" : "Pyrmont",
            "types" : [ "locality", "political" ]
         },
         {
            "long_name" : "NSW",
            "short_name" : "NSW",
            "types" : [ "administrative_area_level_1", "political" ]
         },
         {
            "long_name" : "AU",
            "short_name" : "AU",
            "types" : [ "country", "political" ]
         },
         {
            "long_name" : "2009",
            "short_name" : "2009",
            "types" : [ "postal_code" ]
         }
      ],
      "events" : [
        {
          "event_id" : "9lJ_jK1GfhX",
          "start_time" : 1293865200,
          "summary" : "<p>A visit from author John Doe, who will read from his latest book.</p>
                       <p>A limited number of signed copies will be available.</p>",
          "url" : "http://www.example.com/john_doe_visit.html"
        }
      ],
      "formatted_address" : "48 Pirrama Road, Pyrmont NSW, Australia",
      "formatted_phone_number" : "(02) 9374 4000",
      "geometry" : {
         "location" : {
           "lat" : -33.8669710,
           "lng" : 151.1958750
         }
      },
      "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
      "id" : "4f89212bf76dde31f092cfc14d7506555d85b5c7",
      "international_phone_number" : "+61 2 9374 4000",
      "name" : "Google Sydney",
      "rating" : 4.70,
      "reference" : "CnRsAAAA98C4wD-VFvzGq-KHVEFhlHuy1TD1W6UYZw7KjuvfVsKMRZkbCVBVDxXFOOCM108n9PuJMJxeAxix3WB6B16c1p2bY1ZQyOrcu1d9247xQhUmPgYjN37JMo5QBsWipTsnoIZA9yAzA-0pnxFM6yAcDhIQbU0z05f3xD3m9NQnhEDjvBoUw-BdcocVpXzKFcnMXUpf-nkyF1w",
      "reviews" : [
         {
            "aspects" : [
               {
                  "rating" : 3,
                  "type" : "quality"
               }
            ],
            "author_name" : "Simon Bengtsson",
            "author_url" : "https://plus.google.com/104675092887960962573",
            "text" : "Just went inside to have a look at Google. Amazing.",
            "time" : 1338440552869
         },
         {
           "aspects" : [
              {
                 "rating" : 3,
                 "type" : "quality"
              }
             ],
            "author_name" : "Felix Rauch Valenti",
            "author_url" : "https://plus.google.com/103291556674373289857",
            "text" : "Best place to work :-)",
            "time" : 1338411244325
         },
         {
           "aspects" : [
              {
                 "rating" : 3,
                 "type" : "quality"
              }
             ],
            "author_name" : "Chris",
            "text" : "Great place to work, always lots of free food!",
            "time" : 1330467089039
         }
      ],
      "types" : [ "establishment" ],
      "url" : "http://maps.google.com/maps/place?cid=10281119596374313554",
      "vicinity" : "48 Pirrama Road, Pyrmont",
      "website" : "http://www.google.com.au/"
   },
   "status" : "OK"
}
以下是我获得结果的方式:

public class PlacesList implements Serializable {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    @Key
    public String status;

    @Key
    public List<Place> results;



}
公共类PlacesList实现可序列化{
/**
* 
*/
私有静态最终长serialVersionUID=1L;
@钥匙
公共字符串状态;
@钥匙
公开名单结果;
}
现在我的问题是:

在我从谷歌得到的结果中,你可以看到照片参考。但它是一个数组,我只需要有第一个photo_参考。我怎样才能在代码中得到它?

JSONObject res = // your google api results
JSONArray photos = res.getJSONArray("photo_reference"); // Extract the JSONArray

// Get the item at index 0, which should be a reference to the first image
String photo = photos.getString(0); 
这将获得对照片的引用,然后看起来您必须对照片API发出另一个请求

https://maps.googleapis.com/maps/api/place/photo?parameters

有关如何使用Photo API的更多信息,请参见

但我在另一节课上获得了结果,请再次查看我编辑的问题。我需要Photo_参考。所以我想做的是把@Key公共字符串photo_作为参考;在课堂上。但这不起作用。你是在问一般如何解析json吗?请再澄清一点?我需要照片参考。所以我想做的是把@Key公共字符串photo_作为参考;在课堂上。但这不起作用
https://maps.googleapis.com/maps/api/place/photo?parameters