iOS Question Error using List with nextarray

enriqueprz

Member
Licensed User
Longtime User
I have this code:

Dim COUNTRIES As List
COUNTRIES = parser.NextArray

but happend this error, in b4a yes it works.

Application_Start
Application_Active
JobName = Job1, Success = true
{"NOMBRE":"PLANIFICACION Y MODELADO"}
Response from server: {"NOMBRE":"PLANIFICACION Y MODELADO"}
Error occurred on line: 52 (menuprincipal)
Expected: NSArray, object type: B4IMap
Stack Trace: (
CoreFoundation <redacted> + 150
libobjc.A.dylib objc_exception_throw + 38
CoreFoundation <redacted> + 0
ITL Profes -[B4IObjectWrapper setObject:] + 324
ITL Profes +[B4IObjectWrapper createWrapper:eek:bject:] + 68
ITL Profes -[B4IJSONParser NextArray] + 96
CoreFoundation <redacted> + 68
CoreFoundation <redacted> + 300
ITL Profes +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1936
ITL Profes -[B4IShell runMethod:] + 496
ITL Profes -[B4IShell raiseEventImpl:method:args::] + 1846
ITL Profes -[B4IShellBI raiseEvent:event:params:] + 1280
ITL Profes -[B4ICommon CallSub4::::] + 346
ITL Profes -[B4ICommon CallSub2::::] + 254
ITL Profes -[b4i_httpjob _complete::] + 414
ITL Profes -[b4i_httputils2service _completejob::::] + 752
ITL Profes -[b4i_httputils2service _hc_responsesuccess::] + 296
CoreFoundation <redacted> + 68
CoreFoundation <redacted> + 300
ITL Profes +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1936
ITL Profes -[B4IShell runMethod:] + 496
ITL Profes -[B4IShell raiseEventImpl:method:args::] + 2060
ITL Profes -[B4IShellBI raiseEvent:event:params:] + 1280
ITL Profes __61-[B4IHttp URLSession:downloadTask:didFinishDownloadingToURL:]_block_invoke + 244
libdispatch.dylib <redacted> + 372
libdispatch.dylib <redacted> + 22
libdispatch.dylib _dispatch_main_queue_callback_4CF + 718
CoreFoundation <redacted> + 8
CoreFoundation <redacted> + 1512
CoreFoundation CFRunLoopRunSpecific + 476
CoreFoundation CFRunLoopRunInMode + 106
GraphicsServices GSEventRunModal + 136
UIKit UIApplicationMain + 1440
ITL Profes main + 116
libdyld.dylib <redacted> + 2
)
 

stevel05

Expert
Licensed User
Longtime User
To help us help you:

Which module is NextArray from? A Library perhaps?

Can you post a project (zip from the file menu) that shows the problem?
 
Upvote 0

enriqueprz

Member
Licensed User
Longtime User
Public Sub Show
If Menup.IsInitialized = False Then
Menup.Initialize("menup")
Menup.RootPanel.LoadLayout("menup")
End If
Main.NavControl.ShowPage(Menup)
'ExecuteRemoteQuery("")

Dim job1 As HttpJob

job1.Initialize("Job1", Me)
job1.Download2("xxxxxxxxxxxxxxxxx", Array As String ("pclavemat","DS7"))
End Sub



Sub JobDone (job As HttpJob)
'ProgressDialogHide
Log("JobName = " & job.JobName & ", Success = " & job.Success)
If job.Success = True Then
Select job.JobName
Case "Job1"
'print the result to the logs
Log(job.GetString)
Dim res As String
res = job.GetString
Log("Response from server: " & res)
Dim parser As JSONParser
parser.Initialize(res)
'add the countries to the ListView
Dim COUNTRIES As List
COUNTRIES = parser.NextArray
If COUNTRIES.Size <> 0 Then
Dim m1 As Map
m1 = COUNTRIES.Get(0)
txtProfesor.Text =m1.Get("NOMBRE")
Else
Msgbox("No existe el Sitio... ","Atencion")
End If
End Select
Else
Log("Error: " & job.ErrorMessage)

End If
job.Release
End Sub
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
OK it's a JSON parser object, I'm afraid I don't have anything to test it on, so I can't help you. If you can post a zipped project with the file to be parsed, someone will be able to help quicker.

Also please use [ CODE][ /CODE] tags (without spaces) to post code, it makes it much more readable.

B4X:
Public Sub Show
If Menup.IsInitialized = False Then
Menup.Initialize("menup")
Menup.RootPanel.LoadLayout("menup")
End If
Main.NavControl.ShowPage(Menup)
'ExecuteRemoteQuery("")

Dim job1 As HttpJob

job1.Initialize("Job1", Me)
job1.Download2("xxxxxxxxxxxxxxxxx", Array As String ("pclavemat","DS7"))
End Sub



Sub JobDone (job As HttpJob)
'ProgressDialogHide
Log("JobName = " & job.JobName & ", Success = " & job.Success)
If job.Success = True Then
Select job.JobName
Case "Job1"
'print the result to the logs
Log(job.GetString)
Dim res As String
res = job.GetString
Log("Response from server: " & res)
Dim parser As JSONParser
parser.Initialize(res)
'add the countries to the ListView
Dim COUNTRIES As List
COUNTRIES = parser.NextArray
If COUNTRIES.Size <> 0 Then
Dim m1 As Map
m1 = COUNTRIES.Get(0)
txtProfesor.Text =m1.Get("NOMBRE")
Else
Msgbox("No existe el Sitio... ","Atencion")
End If
End Select
Else
Log("Error: " & job.ErrorMessage)

End If
job.Release
End Sub
 
Upvote 0
Top