iOS Question error un map object

enriqueprz

Member
Licensed User
Longtime User
i have the next code

B4X:
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 Map 
                COUNTRIES = parser.NextObject 
                'If <> 0 Then 
                    'Dim m1 As Map
                    'm1 = COUNTRIES.Get(0)
                    Dim listamaterias As List
                    listamaterias.Initialize 
                   
                    'For t=0 To COUNTRIES.Size 
                        Log(COUNTRIES.Size)
                        'listamaterias.Add(COUNTRIES.Get("NOMBRE"))
                    'Next 
               
                    txtMaterias.SetItems(0,listamaterias)
                    'For Each TMP As Map In COUNTRIES 
                '    '    txtProfesor.Text =COUNTRIES.Get("NOMBRE")
                '        txtMaterias.
                '    Next 
                'Else
                '    Msgbox("No existe el Sitio... ","Atencion") 
                'End If
        End Select
    Else
        Log("Error: " & job.ErrorMessage)

    End If
    job.Release
End Sub

but happens the next error in the call to COUNTRIES.size

Application_Start
Application_Active
JobName = Job1, Success = true
[{"NOMBRE":"PLANIFICACION Y MODELADO "},{"NOMBRE":"TOPICOS SELECTOS DE INGENIERIA DE SOFTWARE "}]
Response from server: [{"NOMBRE":"PLANIFICACION Y MODELADO "},{"NOMBRE":"TOPICOS SELECTOS DE INGENIERIA DE SOFTWARE "}]
Error occurred on line: 61 (menuprincipal)
Method not found: Size, target: (
"(read only map) {\n NOMBRE = \"PLANIFICACION Y MODELADO \";\n}",
"(read only map) {\n NOMBRE = \"TOPICOS SELECTOS DE INGENIERIA DE SOFTWARE \";\n}"
)
Stack Trace: (
CoreFoundation <redacted> + 150
libobjc.A.dylib objc_exception_throw + 38
CoreFoundation <redacted> + 0
ITL Profes +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 442
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
)


help please
 

billzhan

Active Member
Licensed User
Longtime User
Response from server: [{"NOMBRE":"PLANIFICACION Y MODELADO "},{"NOMBRE":"TOPICOS SELECTOS DE INGENIERIA DE SOFTWARE "}]

res is a json array(b4a/b4i list) which contains two maps. You should use

B4X:
Dim COUNTRIESList As List = parser.NextArray
Dim map1 as map=COUNTRIESList.Get(0)
Dim map2 as map=COUNTRIESList.Get(1)
 
Upvote 0
Top