0

I tried to parse JSONArray to pojoclass, using GSON, but I got errors and don't know where the point of failure is. Here my 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}}]

I want something like this:

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

But I get this error:

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

I would be glad for any help.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
BestPractice2Go
  • 285
  • 4
  • 16
  • You are trying to parse a JSON array. Try this: [Using GSON to parse a JSON array](http://stackoverflow.com/questions/18421674/using-gson-to-parse-a-json-array) – Chris Nov 14 '16 at 18:19
  • `Content` is *one object*, your JSON is an array `[]`. – OneCricketeer Nov 14 '16 at 18:21

0 Answers0