Spanish [SOLUCIONADO][SOLVED]URGENTE..... ERROR!!!!!

figorra

Member
Licensed User
Longtime User
Tengo este código PHP


PHP:
<?php
      session_start();
      include('class.consultas.php');
      $usuario         = $_GET['username'];
      $password        = $_GET['password'];
      $ObjetosPermisos = new Permisos;
      $Estatus         = 0;
      $Login           = $ObjetosPermisos->ValidacionLogin($usuario,$password);
 
      if(!empty($Login)){
           foreach ($Login as $key => $value) {
               $Id             = $value['ID'];
               $Nombre            = $value['NOMBRE'];
                        $Apellido               = $value['APELLIDOS'];
               $Verificado     = $value['VERIFICADO'];
               $Estatus_User   = $value['ESTATUS'];
               if($Verificado==0){
                   $Estatus = 3;
               }elseif($Estatus_User==0) {
                   # code...
                   $Estatus = 2;
               }else{
                   $Estatus = 1;
               }
               if($Estatus==1){
                   $_SESSION['USERNO'] = $Nombre;
                   $_SESSION['USERID'] = $Id;
               }
           }
      }else{
          $Estatus     = 0;
      }
     
         
          $Envio = array(
                "id" => $Id,
                "nombre" => $Nombre,
                "apellidos" => $Apellido,
                "verificado" => $Verificado,
                "estado" => (string)$Estatus,
                "usuario" => $usuario,
                "clave" => $password
          );
         
      //echo $Estatus;
          print json_encode($Envio);
?>

que me devuelve datos de la base de datos según usuario y pass......

Y este otro para recoger los datos en B4A


B4X:
#Region  Project Attributes
    #ApplicationLabel: xxxx
    #VersionCode: 1
    #VersionName:
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: True
#End Region

#AdditionalRes: ../LibRes

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals

    Dim Temporizador As Timer
    Public NombreUsuario As String
    Public NUHSA As String
   
    Dim Id As String
    Dim Usuario As String
    Dim Clave As String
    Dim Nombre As String
    Dim Apellidos As String
    Dim Verificado As String
    Dim Estado As String

End Sub

Sub Globals
   
    Private lblusuario As Label
    Private lblclave As Label
    Private txtusuario As EditText
    Private txtcodigo As Label
    Private txtclave As EditText
    Private login As Button
    Private salir As Button
   
   
    Dim loguear As HttpJob
    Dim res As String
    Dim parseo As JSONParser
    Dim variables As List
   
    Dim forceClose As Boolean
    forceClose = False
   
    Dim Beep As Beeper
    Dim BeepMal As Beeper
   
End Sub

Sub Activity_Create(FirstTime As Boolean)

    Activity.LoadLayout("login")
    loguear.Initialize("registro", Me)
   
    Dim cs As CSBuilder
    cs.Initialize.Size(20).Typeface(Typeface.SANS_SERIF)
    cs.Image(LoadBitmap(File.DirAssets, "nzero_p.jpg"), 30dip, 30dip, False).Append("  NZero")
    cs.BackgroundColor(Colors.Blue)
    cs.PopAll
   
    Temporizador.Initialize("Tiempo",2000)
    Temporizador.Enabled = False

    Activity.Title = cs
    Beep.Initialize(300, 500) '300 milliseconds, 500 hz
    BeepMal.Initialize(300, 800) '300 milliseconds, 800 hz

End Sub

Sub Tiempo_tick
    txtcodigo.Text = ""
    Temporizador.Enabled = False
End Sub

Sub Activity_Resume
    If forceClose Then ExitApplication
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub login_Click
   
    loguear.Download2("http://xxxx.xxx/xxxx/xxx.php", Array As String("username", txtusuario.Text, "password", txtclave.Text))
   
End Sub

Sub salir_Click
   
    forceClose = True
    Activity.Finish
   
End Sub

Sub JobDone (Job As HttpJob)
   
    If Job.Success Then
       
        res = Job.GetString
       
        parseo.Initialize(res)
       
        variables = parseo.NextArray ' **** LINEA 111 que da el error ****
       
        For Each variable As Map In variables
       
            Id = variable.Get("id")
            Usuario = variable.Get("usuario")
            Clave = variable.Get("clave")
            Nombre = variable.Get("nombre")
            Apellidos = variable.Get("apellido")
            Verificado = variable.Get("verificado")
            Estado = variable.Get("estado")
           
        Next
       
       
        Select Estado
           
            Case "3"
                txtcodigo.Text = "Usuario no verificado"
                BeepMal.Beep
               
            Case "2"
                txtcodigo.Text = "Usuario desactivado"
                BeepMal.Beep

            Case "1"
                txtcodigo.Text = "Usuario Admitido"
                Beep.Beep
                StartActivity("Escaneo")

            Case "0"
                txtcodigo.Text = "Usuario o clave erronea"
                BeepMal.Beep
           
        End Select
       
        Temporizador.Enabled = True
       
    End If
   
End Sub

El JSON me devuelve este resultado:

{"id":"2","nombre":"kiko","apellidos":"ape ape2","verificado":"1","estado":"1","usuario":"1234","clave":"4321"}


El LOG me dice esto......


Registo conectado a: samsung SM-G930F
--------- beginning of main
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
main_jobdone (java line: 451)
java.lang.RuntimeException: JSON Array expected.
at anywheresoftware.b4a.objects.collections.JSONParser.NextArray(JSONParser.java:62)
at b4a.example.main._jobdone(main.java:451)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
at anywheresoftware.b4a.keywords.Common$11.run(Common.java:1154)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6944)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
java.lang.RuntimeException: JSON Array expected.
main_jobdone (java line: 451)
java.lang.RuntimeException: JSON Array expected.
at anywheresoftware.b4a.objects.collections.JSONParser.NextArray(JSONParser.java:62)
at b4a.example.main._jobdone(main.java:451)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
at anywheresoftware.b4a.keywords.Common$11.run(Common.java:1154)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6944)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
java.lang.RuntimeException: JSON Array expected.
Copying updated assets files (1)
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
Error occurred on line: 112 (Main)
java.lang.RuntimeException: JSON Array expected.
at anywheresoftware.b4a.objects.collections.JSONParser.NextArray(JSONParser.java:62)
at b4a.example.main._jobdone(main.java:510)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at anywheresoftware.b4a.BA$2.run(BA.java:360)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6944)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
Error occurred on line: 111 (Main)
java.lang.RuntimeException: JSON Array expected.
at anywheresoftware.b4a.objects.collections.JSONParser.NextArray(JSONParser.java:62)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at anywheresoftware.b4a.BA$2.run(BA.java:360)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6944)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
Error occurred on line: 111 (Main)
java.lang.RuntimeException: JSON Array expected.
at anywheresoftware.b4a.objects.collections.JSONParser.NextArray(JSONParser.java:62)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at anywheresoftware.b4a.BA$2.run(BA.java:360)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6944)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
Error occurred on line: 111 (Main)
java.lang.RuntimeException: JSON Array expected.
at anywheresoftware.b4a.objects.collections.JSONParser.NextArray(JSONParser.java:62)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at anywheresoftware.b4a.BA$2.run(BA.java:360)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6944)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)

Llevo leyendo de TODO y los códigos de otros compañeros funcionan, pero el mío no......
 

DonManfred

Expert
Licensed User
Longtime User
java.lang.RuntimeException: JSON Array expected.

Sorry i do not speak your language.
BUT

The result is a MAP, but you are trying to get a LIST from the parser.

http://basic4ppc.com:51042/json/index.html

B4X:
Dim parser As JSONParser
parser.Initialize(<text>)
Dim root As Map = parser.NextObject
Dim apellidos As String = root.Get("apellidos")
Dim verificado As String = root.Get("verificado")
Dim estado As String = root.Get("estado")
Dim clave As String = root.Get("clave")
Dim usuario As String = root.Get("usuario")
Dim id As String = root.Get("id")
Dim nombre As String = root.Get("nombre")
 
Last edited:

figorra

Member
Licensed User
Longtime User
java.lang.RuntimeException: JSON Array expected.

Sorry i do not speak your language.
BUT

The result is a MAP, but you are trying to get a LIST from the parser.

http://basic4ppc.com:51042/json/index.html

B4X:
Dim parser As JSONParser
parser.Initialize(<text>)
Dim root As Map = parser.NextObject
Dim apellidos As String = root.Get("apellidos")
Dim verificado As String = root.Get("verificado")
Dim estado As String = root.Get("estado")
Dim clave As String = root.Get("clave")
Dim usuario As String = root.Get("usuario")
Dim id As String = root.Get("id")
Dim nombre As String = root.Get("nombre")


Solved, THX so much
 
Top