Note that there are some explanatory texts on larger screens.

plurals
  1. POcom.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING
    text
    copied!<p>This is my first approach to serialization using Gson. I recive facebook response to my android application like this</p> <p>My Json: </p> <pre><code> {"data": [ { "pic_square": "https://fbcdn-profile-a.akamaihd.netxxxx1388091435_797626998_q.jpg", "uid": "10202xxx852765", "name": "Mister X" }, { "pic_square": "https://fbcdn-profile-a.akamaihd.netxxxx1388091435_797626998_q.jpg", "uid": "10202xxx852765", "name": "Mister X" } ] } try { final GsonBuilder builder = new GsonBuilder(); final Gson gson = builder.create(); JSONObject data= response.getGraphObject().getInnerJSONObject(); FacebookResponses facebookResponses= gson.fromJson(data.toString(),FacebookResponses.class); //exception here Log.i(TAG, "Result: " + facebookResponses.toString()); } catch (JsonSyntaxException e) { e.printStackTrace(); </code></pre> <p>} My class</p> <pre><code>public class FacebookResponses implements Serializable { private static final long serialVersionUID = 1L; @SerializedName("data"); private FacebookRisp[] data; } class FacebookRisp implements Serializable { private static final long serialVersionUID = 1L; @SerializedName("pic_square") private String[] pic_square; @SerializedName("uid") private String[] uid; @SerializedName("name") private String[] name; public String[] getPic_square() { return pic_square; } public void setPic_square(String[] pic_square) { this.pic_square = pic_square; } public String[] getUid() { return uid; } public void setUid(String[] uid) { this.uid = uid; } public String[] getName() { return name; } public void setName(String[] name) { this.name = name; } } </code></pre> <p>I get com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 118</p> <p>UPDATE: I modified the answer of aegean, the problem were <strong>[]</strong> </p> <pre><code>@SerializedName("pic_square") private String**[]** pic_square; //ex here and others </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload