使用GSON将JsonArray解析为POJO类

时间:2016-11-14 18:13:31

标签: java json gson

我尝试使用GSON将JSONArray解析为pojoclass,但是我遇到了错误,并且不知道故障点在哪里。在这里我的JsonArray:

[{"_id":"5829fce93c67d915b82cb93d","content":[{"content1":"first textcontent"},{"image1":"link to image"},{"content2":"second contenttext"}],"shortDescription":"really short","name":"first tutorial","__v":0,"updated":"2016-11-14T18:05:29.540Z","created_at":"2016-11-14T18:05:29.540Z","total_clicks":0,"likes":0,"community":{"area":"MVVM","name":"Android","id":1},"author":{"author_email":"me@me.de","author_name":"Me me","author_id":6}}]

我想要这样的事情:

Content c1 = gson.fromJson(response.toString(), Content.class);

但是我收到了这个错误:

com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $

我很乐意提供任何帮助。

0 个答案:

没有答案
相关问题