OnResponse code :
card_list = new Gson().fromJson(_response, new TypeToken>>(){}.getType()); if (card_list.size() > 5) { recyclerview1.setAdapter(new Recyclerview1Adapter(card_list)); }else{ SketchwareUtil.showMessage(getApplicationContext(), _response); }
Json 200 Result like :
{ "user": [ { "id": "string", "address": "string", "contact": "string", "name": "string", "description": "string", "image_url": "" } ], "next": "string" }
But have the error when opening an activity :
BEGIN_ARRAY but was STRING at line 1 column 1
Please help me solve the code to retrieve json array to listmap for recyclerview in java android or sketchware
2
Answers
If you know the JSON values, you can be explicit.
Here is an example, where s is the String.
Output
If not, define the type-parameter as Object, and cast the Map value.
Output
The warning is there, Array was expected but found string, please show your response model for more context.
From your json response model class or model data class, user should be an array like below.
For Kotlin
Java Should be: