预期BEGIN_OBJECT但在STRING第2行第1列路径$

时间:2017-03-06 16:50:57

标签: json retrofit2 android gson

public interface notiIterface {
    @GET("user/get_notifications")
    Call<full_noti_sec> getNotification(@Query("userid") String userid, @Query("session") String session);
}

此代码给出了一个错误:

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

这是我的JSON数据:

{
  "status": true,
  "message": "Notifications fetched.",
  "data": [
    {
      "id": "69",
      "type": "liked",
      "text": "Sandip Ghosh liked your photo.",
      "for_userid": "56",
      "from_userid": "55",
      "for_image": "54",
      "seen": "0",
      "username": "sandip",
      "firstname": "Sandip",
      "lastname": "Ghosh",
      "imgname": ""
    },
    {
      "id": "64",
      "type": "liked",
      "text": "Sandip Ghosh liked your photo.",
      "for_userid": "56",
      "from_userid": "55",
      "for_image": "54",
      "seen": "0",
      "username": "sandip",
      "firstname": "Sandip",
      "lastname": "Ghosh",
      "imgname": ""
    },
    {
      "id": "63",
      "type": "liked",
      "text": "Sandip Ghosh liked your photo.",
      "for_userid": "56",
      "from_userid": "55",
      "for_image": "54",
      "seen": "0",
      "username": "sandip",
      "firstname": "Sandip",
      "lastname": "Ghosh",
      "imgname": ""
    },
    {
      "id": "62",
      "type": "commented",
      "text": "Sandip Ghosh commented onyour photo.",
      "for_userid": "56",
      "from_userid": "55",
      "for_image": "54",
      "seen": "0",
      "username": "sandip",
      "firstname": "Sandip",
      "lastname": "Ghosh",
      "imgname": ""
    },
    {
      "id": "61",
      "type": "liked",
      "text": "Sandip Ghosh liked your photo.",
      "for_userid": "56",
      "from_userid": "55",
      "for_image": "53",
      "seen": "0",
      "username": "sandip",
      "firstname": "Sandip",
      "lastname": "Ghosh",
      "imgname": ""
    },
    {
      "id": "27",
      "type": "Follow",
      "text": "Sandip Ghosh started following you",
      "for_userid": "56",
      "from_userid": "55",
      "for_image": "0",
      "seen": "1",
      "username": "sandip",
      "firstname": "Sandip",
      "lastname": "Ghosh",
      "imgname": ""
    }
  ]
}

我尝试了一切,但没有任何作用。我正在研究retrofit2并尝试在stackoverflow上提供的每个解决方案但没有任何作用。请任何人帮助我,我试图解决这个错误从2周但没有结果。

0 个答案:

没有答案