"D / Error.Response: com.android.volley.ParseError: com.google.gson.JsonSyntaxException: Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $" [closed]

-3

I have a listview that displays database stores. To this day, in the morning, it was displayed and now no more and this error / warning appears in the console

  

D / Error.Response: com.android.volley.ParseError: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $

What does this mean?

Follow the code:

private void getAgenda(int idusuario) {

    int opcao = 3; //mostrar agenda do cliente
    final ArrayList<ConsultarPojo> agendaCliente = new ArrayList<>();
    RequestQueue queue = Volley.newRequestQueue(this);
    GsonRequest<ConsultarPojo[]> request = new GsonRequest<>("http://reservacomdomanda.com/areaAdmin/api/admin_estabelecimento/reqScheduleProJson.php?" +
            "idcliente="+idusuario+"&opcao="+opcao, ConsultarPojo[].class, null, new Response.Listener<ConsultarPojo[]>() {

        @Override
        public void onResponse(final ConsultarPojo[] response) {
            //Log.d("TAG", "Retorno... " + response.toString());
            for (int i = 0; i < response.length; i++) {
                ConsultarPojo agc = new ConsultarPojo();
                agc.idagendamentoProfissional = response[i].idagendamentoProfissional;
                agc.estabelecimento = response[i].estabelecimento;
                agc.unidade = response[i].unidade;
                agc.dia = response[i].dia;
                agc.hora = response[i].hora;
                agc.nome = response[i].nome;
                agc.funcao = response[i].funcao;
                agendaCliente.add(agc);
            }

            ArrayAdapter<ConsultarPojo> adapter = new ArrayAdapter<ConsultarPojo>(ConsultarActivity.this, android.R.layout.simple_list_item_1, agendaCliente);
            lvReservas = ((ListView)findViewById(R.id.lvReservas));
            lvReservas.setAdapter(adapter);
            lvReservas.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                    //Log.d("Mensagem", "Id "+response[i].idagendamentoProfissional);
                    String idagendamento = response[i].idagendamentoProfissional;

                    Intent intentDetalhesAgendamento = new Intent(ConsultarActivity.this, DetalhesAgendamentoActivity.class);
                    intentDetalhesAgendamento.putExtra("idagendamento", idagendamento);
                    startActivity(intentDetalhesAgendamento);
                }
            });


        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            Log.d("Error.Response", String.valueOf(error));
        }
    });
    queue.add(request);
}
    
asked by anonymous 11.12.2017 / 17:34

1 answer

0

This is because JSON is malformed, so I opened the URL link and then I noticed the problem

  

Parse error: syntax error, unexpected 'default' (T_DEFAULT) in reqScheduleProJson.php on line 191

It is not generating a JSON, it is an error in your PHP, solving the problem will solve the rest probably.

You probably wrote something like:

switch (...) {
  case ...:
    ...
  case default:
    ...

When the correct one should be:

switch (...) {
  case ...:
    ...
  default:
    ...
    
11.12.2017 / 17:42