search
HomeJavaBEGIN_ARRAY but at row 1, column 1 is STRING java android sketchware

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.

Question content

Response code:

65bee13b5a05d

json 200 The results are as follows:

65bee13b5a06c

But 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

Solution

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

65bee13be98af

java 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!

Statement
This article is reproduced at:stackoverflow. If there is any infringement, please contact admin@php.cn delete

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools