Bonjour,
Après une requête ajax, j'obtiens un json:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
 
{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "Place Petite Pce du Pontel",
               "short_name" : "Place Petite Pce du Pontel",
               "types" : [ "route" ]
            },
            {
               "long_name" : "Ambert",
               "short_name" : "Ambert",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Puy-de-Dôme",
               "short_name" : "63",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Auvergne",
               "short_name" : "Auvergne",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "France",
               "short_name" : "FR",
               "types" : [ "country", "political" ]
            },
            {
               "long_name" : "63600",
               "short_name" : "63600",
               "types" : [ "postal_code" ]
            }
         ],
         "formatted_address" : "Place Petite Pce du Pontel, 63600 Ambert, France",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 45.5496020,
                  "lng" : 3.7436630
               },
               "southwest" : {
                  "lat" : 45.5495030,
                  "lng" : 3.7433630
               }
            },
            "location" : {
               "lat" : 45.5496020,
               "lng" : 3.7433630
            },
            "location_type" : "GEOMETRIC_CENTER",
            "viewport" : {
               "northeast" : {
                  "lat" : 45.55090148029150,
                  "lng" : 3.744861980291502
               },
               "southwest" : {
                  "lat" : 45.54820351970850,
                  "lng" : 3.742164019708497
               }
            }
         },
         "partial_match" : true,
         "types" : [ "route" ]
      }
   ],
   "status" : "OK"
}
Ensuite dans mon code java je veux parcourir les données et j'ai :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
 
URLConnection conn = url.openConnection();
conn.setRequestProperty("Accept", "application/json");
ObjectMapper mapper = new ObjectMapper();
JsonNode root = mapper.readTree(conn.getInputStream());
JsonNode results = root.get("results");
// j'affiche les données
log.trace("json adresse {}",results.path("geometry").toString());
Mais je n'obtiens rien en sortie.
Quelqu'un a une idée ?