php editor Zimo brings you an article about solutions to problems encountered in programming. When writing code, sometimes you will encounter some error prompts, such as the "STRING java android sketchware" error in row 1 and column 1. This error message actually appears when using the wrong array writing method. Below we will work together to solve this problem so that the code can run normally.
Response code:
65bee13b5a05djson 200 The results are as follows:
65bee13b5a06cBut an error occurred when opening the activity:
begin_array, but in row 1, column 1 is string
Please help me with the code to retrieve json array to list map for recyclerview in java android or sketchware
Try your code like this:
try { jsonobject jsonresponse = new jsonobject(_response); jsonarray userarray = jsonresponse.getjsonarray("user"); card_list = new gson().fromjson(userarray.tostring(), new typetoken<list<map<string, string>>>(){}.gettype()); if (card_list.size() > 5) { recyclerview1.setadapter(new recyclerview1adapter(card_list)); } else { sketchwareutil.showmessage(getapplicationcontext(), "not enough data for recyclerview"); } } catch (jsonexception e) { e.printstacktrace(); sketchwareutil.showmessage(getapplicationcontext(), "error parsing json"); }
The warning is right there, array expected but string found, show your response model for more context. From your json response model class or model data class, users should be an array like below.
For Kotlin
65bee13be98afjava should be:
public class Data{ public ArrayList<User> user; public String next; } public class User{ public String id; public String address; public String contact; public String name; public String description; public String image_url; }
The above is the detailed content of BEGIN_ARRAY but at row 1, column 1 is STRING java android sketchware. For more information, please follow other related articles on the PHP Chinese website!