質問編集履歴

3

呼び出し元のコードを追加

2015/11/12 08:43

投稿

rontec
rontec

スコア169

test CHANGED
File without changes
test CHANGED
@@ -215,3 +215,63 @@
215
215
  ~
216
216
 
217
217
  ```
218
+
219
+
220
+
221
+ 以下呼び出し元
222
+
223
+
224
+
225
+ ```java
226
+
227
+ public クラスA Access(String url) throws IOException {
228
+
229
+ クラスA instagramData;
230
+
231
+ try {
232
+
233
+ HttpRequestFactory requestFactory = httpTransport.createRequestFactory();
234
+
235
+ GenericUrl genericUrl = new GenericUrl(url);
236
+
237
+ HttpRequest req = requestFactory.buildGetRequest(genericUrl);
238
+
239
+ HttpResponse res = req.execute();
240
+
241
+
242
+
243
+ try {
244
+
245
+ instagramData = asInstagramObject(res.parseAsString());
246
+
247
+ } finally {
248
+
249
+ res.disconnect();
250
+
251
+ }
252
+
253
+ } finally {
254
+
255
+ httpTransport.shutdown();
256
+
257
+ }
258
+
259
+ return instagramData;
260
+
261
+ }
262
+
263
+
264
+
265
+ // Json文字列をInstagramObjectに変換
266
+
267
+ private クラスA asInstagramObject(String stringJson) throws IOException {
268
+
269
+ ObjectMapper mapper = new ObjectMapper();
270
+
271
+ クラスA json = mapper.readValue(stringJson, クラスA.class);
272
+
273
+ return json;
274
+
275
+ }
276
+
277
+ ```

2

表題がふさわしくなかったため

2015/11/12 08:43

投稿

rontec
rontec

スコア169

test CHANGED
@@ -1 +1 @@
1
- LinkedHashMapを指定クラスにマッピング出来ない
1
+ LinkedHashMapを指定クラスにキャスト出来ない
test CHANGED
File without changes

1

swordone様からのご指摘により、記載するコードを増設しました。

2015/11/12 02:31

投稿

rontec
rontec

スコア169

test CHANGED
File without changes
test CHANGED
@@ -42,7 +42,59 @@
42
42
 
43
43
  @Key("tags")
44
44
 
45
+ private List<String> tsgs;
46
+
47
+ @Key("type")
48
+
49
+ private String type;
50
+
51
+ @Key("location")
52
+
53
+ private Object location;
54
+
55
+ @Key("comments")
56
+
57
+ private HashMap<String, Object> comments;
58
+
59
+ @Key("filter")
60
+
61
+ private Object filter;
62
+
63
+ @Key("created_time")
64
+
65
+ private Object created_time;
66
+
67
+ @Key("link")
68
+
69
+ private String link;
70
+
71
+ @Key("likes")
72
+
73
+ private HashMap<String, Object> likes;
74
+
75
+ @Key("images")
76
+
77
+ private HashMap<String, Object> images;
78
+
79
+ @Key("users_in_photo")
80
+
81
+ private Object users_in_photo;
82
+
83
+ @Key("caption")
84
+
85
+ private HashMap<String, Object> caption;
86
+
87
+ @Key("user_has_liked")
88
+
89
+ private Object user_has_liked;
90
+
91
+ @Key("id")
92
+
45
-
93
+ private String id;
94
+
95
+ @Key("user")
96
+
97
+ private HashMap<String, String> user;
46
98
 
47
99
  }
48
100
 
@@ -56,9 +108,19 @@
56
108
 
57
109
  ```java
58
110
 
111
+ public List<HashMap<String, Object>> getInstagramImageData() {
112
+
113
+ List<HashMap<String, Object>> instagramImageList = new ArrayList<>();
114
+
115
+
116
+
59
117
  for (DataBreakdown oneData : data) {
60
118
 
119
+ HashMap<String, Object> instagramImageData = new HashMap<>();
120
+
121
+ instagramImageData.put("images", oneData.getImages());
122
+
61
-
123
+ instagramImageList.add(instagramImageData);
62
124
 
63
125
  }
64
126