从json获取嵌套值

时间:2018-05-02 13:21:47

标签: javascript reactjs react-native

我试图从谷歌地理编码API检索数据。我可以回复。但是如果我尝试更多地定义它,比如response.results.geometry那么它是不确定的? 来自谷歌的JSon回复:

{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "Detroit",
               "short_name" : "Detroit",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Wayne County",
               "short_name" : "Wayne County",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Michigan",
               "short_name" : "MI",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "USA",
               "short_name" : "US",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Detroit, Michigan, USA",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 42.45023,
                  "lng" : -82.91045099999999
               },
               "southwest" : {
                  "lat" : 42.255192,
                  "lng" : -83.287959
               }
            },
            "location" : {
               "lat" : 42.331427,
               "lng" : -83.0457538
           {........}

0 个答案:

没有答案