0

I have a hosted json api which is

{
  "s": "S1_Server",
  "code": "200",
  "msg": [
    {
      "tp": 0,
      "uid": "49VsjdXy",
      "liked": 0,
      "score": 10050,
      "status": "approved",
      "is_block": 0,
      "description": "shehnaazgill",
      "country": "",
      "city": "",
      "_id": "60661b0bbc688f13120c3be9",
      "id": 97114693,
      "fb_id": "6002970333888555542222990190500080030",
      "user_info": {
        "first_name": "Navi",
        "last_name": "",
        "fb_id": "6002970333888555542222990190500080030",
        "profile_pic": "http://cdn2.takatakind.com/app_api/upload/images/navi8481.jpeg",
        "gender": "f",
        "verified": "0",
        "_id": "606603bea20cc0a848ff7604",
        "username": "@navi84815"
      },
      "count": {
        "like_count": 88675,
        "video_comment_count": 1,
        "view": 0,
        "_id": "60661b0bbc688f13120c3beb"
      },
      "video": "http://tx-ind-cdn.snackvideo.in/upic/2021/01/07/23/BMjAyMTAxMDcyMzAxMjZfMTUwMDAwNDkzMzg0MjMyXzE1MDAwMTIwNzAzNDk1NF8wXzM=_b_Ba5cf966fa387bbefc9fa142b60b6da16.mp4?tag=1-1617304330-s-0-1xxjfwj2pw-281add254dc7be5d",
      "thum": "http://tx-ind-pic.snackvideo.in/upic/2021/01/07/23/BMjAyMTAxMDcyMzAxMjZfMTUwMDAwNDkzMzg0MjMyXzE1MDAwMTIwNzAzNDk1NF8wXzM=_offn_B127ecd9c0578708b6fab90cbc99b9b08.webp?tag=1-1617304330-s-0-jmawl789qx-6ff23f7980b3cb13",
      "gif": "http://tx-ind-pic.snackvideo.in/upic/2021/01/07/23/BMjAyMTAxMDcyMzAxMjZfMTUwMDAwNDkzMzg0MjMyXzE1MDAwMTIwNzAzNDk1NF8wXzM=_offn_B127ecd9c0578708b6fab90cbc99b9b08.webp?tag=1-1617304330-s-0-jmawl789qx-6ff23f7980b3cb13",
      "sound": {
        "id": 0,
        "sound_name": "",
        "description": "",
        "thum": "",
        "section": "",
        "_id": "60661b0bbc688f13120c3bec",
        "created": "2021-04-01T19:12:11.189Z",
        "audio_path": {
          "mp3": "http://cdn2.takatakind.com/app_api/upload/audio/.mp3",
          "acc": "http://cdn2.takatakind.com/app_api/upload/audio/.aac"
        }
      },
      "created": "2021-04-01T19:12:11.189Z",
      "__v": 0
    }
  ]
}

I created a pojo classes accordingly using this website https://jsonschema2pojo.org/

in Mainactivity.java i have written volley String code

StringRequest request = new StringRequest(videoURL, response -> {
            GsonBuilder gsonBuilder = new GsonBuilder();
            Gson gson = gsonBuilder.create();
            Json[] jsonList = gson.fromJson(response, Json[].class);
            Toast.makeText(this, ""+jsonList, Toast.LENGTH_SHORT).show();
        }, error -> {});
        RequestQueue queue = Volley.newRequestQueue(this);
        queue.add(request);

when i try to run this i get a error Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $.

0 Answers0