Android Question error java.lang.RuntimeException: JSON Object expected.

Makumbi

Well-Known Member
Licensed User
Please help iam trying run this code but am getting error below
B4X:
If Account.Text="" Then
        MsgboxAsync("Select the Student Name from the List","SMIS")
        Return
        Else
            If Latestdata.Checked=True Then
        If Classr.Text.Contains("S1")=True Or Classr.Text.Contains("S2")=True  Or Classr.Text.Contains("S3")=True Or Classr.Text.Contains("S4")=True Then
            StartActivity(Academics)
            Else
            If Classr.Text.Contains("P1")=True Or Classr.Text.Contains("P2")=True  Or Classr.Text.Contains("P3")=True Or Classr.Text.Contains("P4")=True Or Classr.Text.Contains("P5")=True Or Classr.Text.Contains("P6")=True Or Classr.Text.Contains("P7")=True Then
                StartActivity(Academics)
                Else
                    If Classr.Text.Contains("S5")=True Or Classr.Text.Contains("S6")=True   Then
                    Dim jt As HttpJob
                    jt.Initialize("", Me)
                        jt.Download("http://kccug.com/Generic_Handler_JSON/HandlerVBAlevelreport.ashx?customerid=" & Account.Text)
                    jt.GetRequest.Timeout = 10000 ' 10 seconds
                    Wait For (jt) JobDone(jt As HttpJob)
                    If jt.Success Then ' if job is success (http status code 200)
                        Dim RetVal As String
                        RetVal = jt.GetString
                        Log(RetVal)
                        
                        If jt.GetString = "[]" Then
                            'MsgboxAsync("No Records to Upload Yet for: " & CustID ,"SMIS")
                                Return
                            Else
                                Dim parser As JSONParser
                                parser.Initialize(jt.GetString)
                                Dim OutputMap As Map = parser.NextObject
                                Log(OutputMap.Size)

                                Dim FieldName As String
                                Dim FieldValue As String

                                For I = 0 To OutputMap.Size - 1
                                    '''Log(OutputMap.GetKeyAt(I) & " = " & OutputMap.GetValueAt(I))
 
                                    FieldName = OutputMap.GetKeyAt(I)
                                    If FieldName.Trim.ToUpperCase.EndsWith("POINTS") Then
                                        FieldValue = OutputMap.GetValueAt(I)
    
                                        Select Case FieldValue.Trim.ToUpperCase
                                            Case "A", "B", "C", "D", "E", "O"
                                                Log(FieldName.Trim & " = " & FieldValue.Trim)
            
                                            Case "1", "2", "3", "4", "5", "6"
                                                Log("  (Numeric score for " & FieldName.Trim & ")")
                
                                            Case "F"
                                                Log("  (No good at " & FieldName.Trim & ")")
            
                                        End Select
                                    End If
                                Next
                                                                    
                                                jt.Release
            Return
                        End If
    End If

                    
            
                    
                    End If
            End If
            End If
    End If
    End If
B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
ExecuteHtml: SELECT DISTINCT Names,Class || Stream As CS,Amount As Balance FROM Balances
6
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
** Service (httputils2service) Start **
[{"Account":"05-00001","Name":"BUGEMBE YASIN ismail","Stream":"A","Category":"Active","Country":"S2","Froms":"\/Date(1545512400000)\/","Tos":"\/Date(1554152400000)\/"},{"Account":"05-00005","Name":"DDAMULIRA GEORGE","Stream":"A","Category":"Active","Country":"S5","Froms":"\/Date(1550091600000)\/","Tos":"\/Date(1559163600000)\/"}]
[{"Account":"05-00001","Name":"BUGEMBE YASIN ismail","Stream":"A","Category":"Active","Country":"S2","Froms":"\/Date(1545512400000)\/","Tos":"\/Date(1554152400000)\/"},{"Account":"05-00005","Name":"DDAMULIRA GEORGE","Stream":"A","Category":"Active","Country":"S5","Froms":"\/Date(1550091600000)\/","Tos":"\/Date(1559163600000)\/"}]
(JSONTokener)  at character 0 of [{"Account":"05-00001","Name":"BUGEMBE YASIN ismail","Stream":"A","Category":"Active","Country":"S2","Froms":"\/Date(1545512400000)\/","Tos":"\/Date(1554152400000)\/"},{"Account":"05-00005","Name":"DDAMULIRA GEORGE","Stream":"A","Category":"Active","Country":"S5","Froms":"\/Date(1550091600000)\/","Tos":"\/Date(1559163600000)\/"}]
Name: BUGEMBE YASIN ismail
Category: Active
Froms: /Date(1545512400000)/
Tos: /Date(1554152400000)/
12/23/2018
23/12/2018
02/04/2019
02/04/2019
[{"Account":"05-00001","Name":"BUGEMBE YASIN ismail","Stream":"A","Category":"Active","Country":"S2","Froms":"\/Date(1545512400000)\/","Tos":"\/Date(1554152400000)\/"},{"Account":"05-00005","Name":"DDAMULIRA GEORGE","Stream":"A","Category":"Active","Country":"S5","Froms":"\/Date(1550091600000)\/","Tos":"\/Date(1559163600000)\/"}]
Name: DDAMULIRA GEORGE
Category: Active
Froms: /Date(1550091600000)/
Tos: /Date(1559163600000)/
14/02/2019
14/02/2019
30/05/2019
30/05/2019
[{"Account":"05-00001","Name":"BUGEMBE YASIN ismail","Stream":"A","Category":"Active","Country":"S2","Froms":"\/Date(1545512400000)\/","Tos":"\/Date(1554152400000)\/"},{"Account":"05-00005","Name":"DDAMULIRA GEORGE","Stream":"A","Category":"Active","Country":"S5","Froms":"\/Date(1550091600000)\/","Tos":"\/Date(1559163600000)\/"}]
** Activity (main) Pause, UserClosed = false **
** Activity (academicextract) Create, isFirst = true **
ExecuteHtml: SELECT DISTINCT Names,Class || Stream As CS,Amount As Balance FROM Balances
** Activity (academicextract) Resume **
** Activity (academicextract) Pause, UserClosed = false **
** Activity (main) Resume **
ExecuteHtml: SELECT DISTINCT Names,Class || Stream As CS,Amount As Balance FROM Balances
6
[{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"MATHEMATICS","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":1},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"BIOLOGY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":2},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"COMPUTER","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":3},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"CHEMISTRY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":4},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"ENTREPRENUERSHIP","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":5},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"HISTORY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":6},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"ADD-MATHS","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":7},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"FINE-ART","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":8},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"CRE","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":9},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"PHYSICS","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":10},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"TOTAL MARKS","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":0,"autofield":11},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"AVERAGE","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":0,"autofield":12},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"POSITIONSTREAM","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":1,"autofield":13},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"OUTOF","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":2,"autofield":14},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"GEOGRAPHY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":15}]
(JSONTokener)  at character 0 of [{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"MATHEMATICS","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":1},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"BIOLOGY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":2},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"COMPUTER","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":3},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"CHEMISTRY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":4},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"ENTREPRENUERSHIP","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":5},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"HISTORY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":6},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"ADD-MATHS","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":7},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"FINE-ART","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":8},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"CRE","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":9},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"PHYSICS","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":10},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"TOTAL MARKS","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":0,"autofield":11},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"AVERAGE","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":0,"autofield":12},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"POSITIONSTREAM","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":1,"autofield":13},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"OUTOF","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":2,"autofield":14},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"GEOGRAPHY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":15}]
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: MATHEMATICS
Total: 0
atk: 1
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: BIOLOGY
Total: 0
atk: 2
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: COMPUTER
Total: 0
atk: 3
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: CHEMISTRY
Total: 0
atk: 4
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: ENTREPRENUERSHIP
Total: 0
atk: 5
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: HISTORY
Total: 0
atk: 6
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: ADD-MATHS
Total: 0
atk: 7
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: FINE-ART
Total: 0
atk: 8
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: CRE
Total: 0
atk: 9
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: PHYSICS
Total: 0
atk: 10
Account: 05-00001
Grade: null
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: TOTAL MARKS
Total: 0
atk: 11
Account: 05-00001
Grade: null
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: AVERAGE
Total: 0
atk: 12
Account: 05-00001
Grade: null
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: POSITIONSTREAM
Total: 1
atk: 13
Account: 05-00001
Grade: null
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: OUTOF
Total: 2
atk: 14
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: GEOGRAPHY
Total: 0
atk: 15
[{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"MATHEMATICS","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":1},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"BIOLOGY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":2},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"COMPUTER","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":3},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"CHEMISTRY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":4},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"ENTREPRENUERSHIP","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":5},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"HISTORY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":6},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"ADD-MATHS","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":7},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"FINE-ART","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":8},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"CRE","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":9},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"PHYSICS","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":10},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"TOTAL MARKS","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":0,"autofield":11},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"AVERAGE","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":0,"autofield":12},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"POSITIONSTREAM","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":1,"autofield":13},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"OUTOF","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":2,"autofield":14},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"GEOGRAPHY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":15}]
(JSONTokener)  at character 0 of [{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"MATHEMATICS","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":1},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"BIOLOGY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":2},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"COMPUTER","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":3},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"CHEMISTRY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":4},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"ENTREPRENUERSHIP","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":5},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"HISTORY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":6},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"ADD-MATHS","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":7},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"FINE-ART","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":8},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"CRE","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":9},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"PHYSICS","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":10},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"TOTAL MARKS","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":0,"autofield":11},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"AVERAGE","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":0,"autofield":12},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"POSITIONSTREAM","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":1,"autofield":13},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"OUTOF","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":2,"autofield":14},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"GEOGRAPHY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":15}]
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: MATHEMATICS
Total: 0
atk: 1
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: BIOLOGY
Total: 0
atk: 2
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: COMPUTER
Total: 0
atk: 3
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: CHEMISTRY
Total: 0
atk: 4
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: ENTREPRENUERSHIP
Total: 0
atk: 5
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: HISTORY
Total: 0
atk: 6
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: ADD-MATHS
Total: 0
atk: 7
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: FINE-ART
Total: 0
atk: 8
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: CRE
Total: 0
atk: 9
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: PHYSICS
Total: 0
atk: 10
Account: 05-00001
Grade: null
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: TOTAL MARKS
Total: 0
atk: 11
Account: 05-00001
Grade: null
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: AVERAGE
Total: 0
atk: 12
Account: 05-00001
Grade: null
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: POSITIONSTREAM
Total: 1
atk: 13
Account: 05-00001
Grade: null
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: OUTOF
Total: 2
atk: 14
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: GEOGRAPHY
Total: 0
atk: 15
** Activity (main) Pause, UserClosed = false **
** Activity (academicextract) Resume **
[{"ACCOUNT":"05-00005","Name":"DDAMULIRA GEORGE","HISP":"","GPPoints":"F","PhyPoints":"","GeogPoints":"","EconPointst":"B","LitPoints":"","IREPoints":"","LugPoints":"","artpoints":"","FoodPoints":"","TDPoints":"","GermanPoints":"","WoodPoints":"","ArabPoints":"","EnterprPoints":null,"SubMathPoints":"F","CompPOINTS":"F","Principle":5,"Subsidiary":0,"TotalPoints":5}]
Error occurred on line: 190 (academicextract)
java.lang.RuntimeException: JSON Object expected.
    at anywheresoftware.b4a.objects.collections.JSONParser.NextObject(JSONParser.java:50)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:733)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:352)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
    at anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:22)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:245)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:137)
    at anywheresoftware.b4a.BA$2.run(BA.java:365)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6077)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
 

walterf25

Expert
Licensed User
Longtime User
Please help iam trying run this code but am getting error below
B4X:
If Account.Text="" Then
        MsgboxAsync("Select the Student Name from the List","SMIS")
        Return
        Else
            If Latestdata.Checked=True Then
        If Classr.Text.Contains("S1")=True Or Classr.Text.Contains("S2")=True  Or Classr.Text.Contains("S3")=True Or Classr.Text.Contains("S4")=True Then
            StartActivity(Academics)
            Else
            If Classr.Text.Contains("P1")=True Or Classr.Text.Contains("P2")=True  Or Classr.Text.Contains("P3")=True Or Classr.Text.Contains("P4")=True Or Classr.Text.Contains("P5")=True Or Classr.Text.Contains("P6")=True Or Classr.Text.Contains("P7")=True Then
                StartActivity(Academics)
                Else
                    If Classr.Text.Contains("S5")=True Or Classr.Text.Contains("S6")=True   Then
                    Dim jt As HttpJob
                    jt.Initialize("", Me)
                        jt.Download("http://kccug.com/Generic_Handler_JSON/HandlerVBAlevelreport.ashx?customerid=" & Account.Text)
                    jt.GetRequest.Timeout = 10000 ' 10 seconds
                    Wait For (jt) JobDone(jt As HttpJob)
                    If jt.Success Then ' if job is success (http status code 200)
                        Dim RetVal As String
                        RetVal = jt.GetString
                        Log(RetVal)
                       
                        If jt.GetString = "[]" Then
                            'MsgboxAsync("No Records to Upload Yet for: " & CustID ,"SMIS")
                                Return
                            Else
                                Dim parser As JSONParser
                                parser.Initialize(jt.GetString)
                                Dim OutputMap As Map = parser.NextObject
                                Log(OutputMap.Size)

                                Dim FieldName As String
                                Dim FieldValue As String

                                For I = 0 To OutputMap.Size - 1
                                    '''Log(OutputMap.GetKeyAt(I) & " = " & OutputMap.GetValueAt(I))
 
                                    FieldName = OutputMap.GetKeyAt(I)
                                    If FieldName.Trim.ToUpperCase.EndsWith("POINTS") Then
                                        FieldValue = OutputMap.GetValueAt(I)
   
                                        Select Case FieldValue.Trim.ToUpperCase
                                            Case "A", "B", "C", "D", "E", "O"
                                                Log(FieldName.Trim & " = " & FieldValue.Trim)
           
                                            Case "1", "2", "3", "4", "5", "6"
                                                Log("  (Numeric score for " & FieldName.Trim & ")")
               
                                            Case "F"
                                                Log("  (No good at " & FieldName.Trim & ")")
           
                                        End Select
                                    End If
                                Next
                                                                   
                                                jt.Release
            Return
                        End If
    End If

                   
           
                   
                    End If
            End If
            End If
    End If
    End If
B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
ExecuteHtml: SELECT DISTINCT Names,Class || Stream As CS,Amount As Balance FROM Balances
6
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
** Service (httputils2service) Start **
[{"Account":"05-00001","Name":"BUGEMBE YASIN ismail","Stream":"A","Category":"Active","Country":"S2","Froms":"\/Date(1545512400000)\/","Tos":"\/Date(1554152400000)\/"},{"Account":"05-00005","Name":"DDAMULIRA GEORGE","Stream":"A","Category":"Active","Country":"S5","Froms":"\/Date(1550091600000)\/","Tos":"\/Date(1559163600000)\/"}]
[{"Account":"05-00001","Name":"BUGEMBE YASIN ismail","Stream":"A","Category":"Active","Country":"S2","Froms":"\/Date(1545512400000)\/","Tos":"\/Date(1554152400000)\/"},{"Account":"05-00005","Name":"DDAMULIRA GEORGE","Stream":"A","Category":"Active","Country":"S5","Froms":"\/Date(1550091600000)\/","Tos":"\/Date(1559163600000)\/"}]
(JSONTokener)  at character 0 of [{"Account":"05-00001","Name":"BUGEMBE YASIN ismail","Stream":"A","Category":"Active","Country":"S2","Froms":"\/Date(1545512400000)\/","Tos":"\/Date(1554152400000)\/"},{"Account":"05-00005","Name":"DDAMULIRA GEORGE","Stream":"A","Category":"Active","Country":"S5","Froms":"\/Date(1550091600000)\/","Tos":"\/Date(1559163600000)\/"}]
Name: BUGEMBE YASIN ismail
Category: Active
Froms: /Date(1545512400000)/
Tos: /Date(1554152400000)/
12/23/2018
23/12/2018
02/04/2019
02/04/2019
[{"Account":"05-00001","Name":"BUGEMBE YASIN ismail","Stream":"A","Category":"Active","Country":"S2","Froms":"\/Date(1545512400000)\/","Tos":"\/Date(1554152400000)\/"},{"Account":"05-00005","Name":"DDAMULIRA GEORGE","Stream":"A","Category":"Active","Country":"S5","Froms":"\/Date(1550091600000)\/","Tos":"\/Date(1559163600000)\/"}]
Name: DDAMULIRA GEORGE
Category: Active
Froms: /Date(1550091600000)/
Tos: /Date(1559163600000)/
14/02/2019
14/02/2019
30/05/2019
30/05/2019
[{"Account":"05-00001","Name":"BUGEMBE YASIN ismail","Stream":"A","Category":"Active","Country":"S2","Froms":"\/Date(1545512400000)\/","Tos":"\/Date(1554152400000)\/"},{"Account":"05-00005","Name":"DDAMULIRA GEORGE","Stream":"A","Category":"Active","Country":"S5","Froms":"\/Date(1550091600000)\/","Tos":"\/Date(1559163600000)\/"}]
** Activity (main) Pause, UserClosed = false **
** Activity (academicextract) Create, isFirst = true **
ExecuteHtml: SELECT DISTINCT Names,Class || Stream As CS,Amount As Balance FROM Balances
** Activity (academicextract) Resume **
** Activity (academicextract) Pause, UserClosed = false **
** Activity (main) Resume **
ExecuteHtml: SELECT DISTINCT Names,Class || Stream As CS,Amount As Balance FROM Balances
6
[{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"MATHEMATICS","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":1},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"BIOLOGY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":2},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"COMPUTER","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":3},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"CHEMISTRY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":4},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"ENTREPRENUERSHIP","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":5},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"HISTORY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":6},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"ADD-MATHS","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":7},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"FINE-ART","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":8},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"CRE","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":9},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"PHYSICS","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":10},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"TOTAL MARKS","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":0,"autofield":11},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"AVERAGE","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":0,"autofield":12},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"POSITIONSTREAM","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":1,"autofield":13},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"OUTOF","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":2,"autofield":14},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"GEOGRAPHY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":15}]
(JSONTokener)  at character 0 of [{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"MATHEMATICS","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":1},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"BIOLOGY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":2},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"COMPUTER","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":3},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"CHEMISTRY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":4},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"ENTREPRENUERSHIP","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":5},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"HISTORY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":6},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"ADD-MATHS","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":7},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"FINE-ART","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":8},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"CRE","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":9},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"PHYSICS","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":10},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"TOTAL MARKS","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":0,"autofield":11},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"AVERAGE","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":0,"autofield":12},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"POSITIONSTREAM","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":1,"autofield":13},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"OUTOF","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":2,"autofield":14},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"GEOGRAPHY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":15}]
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: MATHEMATICS
Total: 0
atk: 1
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: BIOLOGY
Total: 0
atk: 2
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: COMPUTER
Total: 0
atk: 3
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: CHEMISTRY
Total: 0
atk: 4
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: ENTREPRENUERSHIP
Total: 0
atk: 5
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: HISTORY
Total: 0
atk: 6
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: ADD-MATHS
Total: 0
atk: 7
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: FINE-ART
Total: 0
atk: 8
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: CRE
Total: 0
atk: 9
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: PHYSICS
Total: 0
atk: 10
Account: 05-00001
Grade: null
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: TOTAL MARKS
Total: 0
atk: 11
Account: 05-00001
Grade: null
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: AVERAGE
Total: 0
atk: 12
Account: 05-00001
Grade: null
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: POSITIONSTREAM
Total: 1
atk: 13
Account: 05-00001
Grade: null
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: OUTOF
Total: 2
atk: 14
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: GEOGRAPHY
Total: 0
atk: 15
[{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"MATHEMATICS","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":1},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"BIOLOGY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":2},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"COMPUTER","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":3},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"CHEMISTRY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":4},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"ENTREPRENUERSHIP","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":5},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"HISTORY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":6},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"ADD-MATHS","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":7},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"FINE-ART","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":8},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"CRE","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":9},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"PHYSICS","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":10},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"TOTAL MARKS","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":0,"autofield":11},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"AVERAGE","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":0,"autofield":12},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"POSITIONSTREAM","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":1,"autofield":13},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"OUTOF","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":2,"autofield":14},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"GEOGRAPHY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":15}]
(JSONTokener)  at character 0 of [{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"MATHEMATICS","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":1},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"BIOLOGY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":2},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"COMPUTER","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":3},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"CHEMISTRY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":4},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"ENTREPRENUERSHIP","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":5},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"HISTORY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":6},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"ADD-MATHS","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":7},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"FINE-ART","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":8},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"CRE","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":9},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"PHYSICS","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":10},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"TOTAL MARKS","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":0,"autofield":11},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"AVERAGE","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":0,"autofield":12},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"POSITIONSTREAM","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":1,"autofield":13},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"OUTOF","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":2,"autofield":14},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"GEOGRAPHY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":15}]
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: MATHEMATICS
Total: 0
atk: 1
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: BIOLOGY
Total: 0
atk: 2
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: COMPUTER
Total: 0
atk: 3
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: CHEMISTRY
Total: 0
atk: 4
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: ENTREPRENUERSHIP
Total: 0
atk: 5
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: HISTORY
Total: 0
atk: 6
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: ADD-MATHS
Total: 0
atk: 7
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: FINE-ART
Total: 0
atk: 8
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: CRE
Total: 0
atk: 9
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: PHYSICS
Total: 0
atk: 10
Account: 05-00001
Grade: null
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: TOTAL MARKS
Total: 0
atk: 11
Account: 05-00001
Grade: null
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: AVERAGE
Total: 0
atk: 12
Account: 05-00001
Grade: null
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: POSITIONSTREAM
Total: 1
atk: 13
Account: 05-00001
Grade: null
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: OUTOF
Total: 2
atk: 14
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: GEOGRAPHY
Total: 0
atk: 15
** Activity (main) Pause, UserClosed = false **
** Activity (academicextract) Resume **
[{"ACCOUNT":"05-00005","Name":"DDAMULIRA GEORGE","HISP":"","GPPoints":"F","PhyPoints":"","GeogPoints":"","EconPointst":"B","LitPoints":"","IREPoints":"","LugPoints":"","artpoints":"","FoodPoints":"","TDPoints":"","GermanPoints":"","WoodPoints":"","ArabPoints":"","EnterprPoints":null,"SubMathPoints":"F","CompPOINTS":"F","Principle":5,"Subsidiary":0,"TotalPoints":5}]
Error occurred on line: 190 (academicextract)
java.lang.RuntimeException: JSON Object expected.
    at anywheresoftware.b4a.objects.collections.JSONParser.NextObject(JSONParser.java:50)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:733)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:352)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
    at anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:22)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:245)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:137)
    at anywheresoftware.b4a.BA$2.run(BA.java:365)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6077)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Somewhere in the response you are getting, you either are getting a line that is not Json Object, or not a Map Object, maybe a List?

Walter
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
According to the JSONTree utility, you should be using NextArray to extract a list and then parse the maps contained in that list.
Link: http://basic4ppc.com:51042/json/index.html

Plus your log is not really clear what is produced by the code posted. Each log of jt.GetString should be followed by a log of OutputMap.Size. I don't see that pattern here. Now and then I see that size, but not all the time. Could be that I don't read your code/log correctly
 
Upvote 0

Makumbi

Well-Known Member
Licensed User
According to the JSONTree utility, you should be using NextArray to extract a list and then parse the maps contained in that list.
Link: http://basic4ppc.com:51042/json/index.html

Plus your log is not really clear what is produced by the code posted. Each log of jt.GetString should be followed by a log of OutputMap.Size. I don't see that pattern here. Now and then I see that size, but not all the time. Could be that I don't read your code/log correctly

after using Link: http://basic4ppc.com:51042/json/index.html this is what was got
B4X:
Dim parser As JSONParser
parser.Initialize(<text>)
Dim root As List = parser.NextArray
For Each colroot As Map In root
 Dim FoodPoints As String = colroot.Get("FoodPoints")
 Dim PhyPoints As String = colroot.Get("PhyPoints")
 Dim EconPointst As String = colroot.Get("EconPointst")
 Dim TDPoints As String = colroot.Get("TDPoints")
 Dim EnterprPoints As String = colroot.Get("EnterprPoints")
 Dim GeogPoints As String = colroot.Get("GeogPoints")
 Dim LitPoints As String = colroot.Get("LitPoints")
 Dim LugPoints As String = colroot.Get("LugPoints")
 Dim CompPOINTS As String = colroot.Get("CompPOINTS")
 Dim Principle As Int = colroot.Get("Principle")
 Dim GermanPoints As String = colroot.Get("GermanPoints")
 Dim TotalPoints As Int = colroot.Get("TotalPoints")
 Dim Name As String = colroot.Get("Name")
 Dim ArabPoints As String = colroot.Get("ArabPoints")
 Dim ACCOUNT As String = colroot.Get("ACCOUNT")
 Dim WoodPoints As String = colroot.Get("WoodPoints")
 Dim artpoints As String = colroot.Get("artpoints")
 Dim SubMathPoints As String = colroot.Get("SubMathPoints")
 Dim Subsidiary As Int = colroot.Get("Subsidiary")
 Dim GPPoints As String = colroot.Get("GPPoints")
 Dim IREPoints As String = colroot.Get("IREPoints")
 Dim HISP As String = colroot.Get("HISP")
Next

But my biggest problem is extracting out A,B,C,D,E,O,F only from the json List as i wanted to use the select
option as it is here
B4X:
Dim FieldName As String
                                Dim FieldValue As String

                                For I = 0 To OutputMap.Size - 1
                                    '''Log(OutputMap.GetKeyAt(I) & " = " & OutputMap.GetValueAt(I))
 
                                    FieldName = OutputMap.GetKeyAt(I)
                                    If FieldName.Trim.ToUpperCase.EndsWith("POINTS") Then
                                        FieldValue = OutputMap.GetValueAt(I)
  
                                        Select Case FieldValue.Trim.ToUpperCase
                                            Case "A", "B", "C", "D", "E", "O"
                                                Log(FieldName.Trim & " = " & FieldValue.Trim)
          
                                            Case "1", "2", "3", "4", "5", "6"
                                                Log("  (Numeric score for " & FieldName.Trim & ")")
              
                                            Case "F"
                                                Log("  (No good at " & FieldName.Trim & ")")
          
                                        End Select
 
Upvote 0

Makumbi

Well-Known Member
Licensed User
According to the JSONTree utility, you should be using NextArray to extract a list and then parse the maps contained in that list.
Link: http://basic4ppc.com:51042/json/index.html

Plus your log is not really clear what is produced by the code posted. Each log of jt.GetString should be followed by a log of OutputMap.Size. I don't see that pattern here. Now and then I see that size, but not all the time. Could be that I don't read your code/log correctly

after using Link: http://basic4ppc.com:51042/json/index.html this is what was got
B4X:
Dim parser As JSONParser
parser.Initialize(<text>)
Dim root As List = parser.NextArray
For Each colroot As Map In root
 Dim FoodPoints As String = colroot.Get("FoodPoints")
 Dim PhyPoints As String = colroot.Get("PhyPoints")
 Dim EconPointst As String = colroot.Get("EconPointst")
 Dim TDPoints As String = colroot.Get("TDPoints")
 Dim EnterprPoints As String = colroot.Get("EnterprPoints")
 Dim GeogPoints As String = colroot.Get("GeogPoints")
 Dim LitPoints As String = colroot.Get("LitPoints")
 Dim LugPoints As String = colroot.Get("LugPoints")
 Dim CompPOINTS As String = colroot.Get("CompPOINTS")
 Dim Principle As Int = colroot.Get("Principle")
 Dim GermanPoints As String = colroot.Get("GermanPoints")
 Dim TotalPoints As Int = colroot.Get("TotalPoints")
 Dim Name As String = colroot.Get("Name")
 Dim ArabPoints As String = colroot.Get("ArabPoints")
 Dim ACCOUNT As String = colroot.Get("ACCOUNT")
 Dim WoodPoints As String = colroot.Get("WoodPoints")
 Dim artpoints As String = colroot.Get("artpoints")
 Dim SubMathPoints As String = colroot.Get("SubMathPoints")
 Dim Subsidiary As Int = colroot.Get("Subsidiary")
 Dim GPPoints As String = colroot.Get("GPPoints")
 Dim IREPoints As String = colroot.Get("IREPoints")
 Dim HISP As String = colroot.Get("HISP")
Next

But my biggest problem is extracting out A,B,C,D,E,O,F only from the json List as i wanted to use the select
option as it is here
B4X:
Dim FieldName As String
                                Dim FieldValue As String

                                For I = 0 To OutputMap.Size - 1
                                    '''Log(OutputMap.GetKeyAt(I) & " = " & OutputMap.GetValueAt(I))
 
                                    FieldName = OutputMap.GetKeyAt(I)
                                    If FieldName.Trim.ToUpperCase.EndsWith("POINTS") Then
                                        FieldValue = OutputMap.GetValueAt(I)
  
                                        Select Case FieldValue.Trim.ToUpperCase
                                            Case "A", "B", "C", "D", "E", "O"
                                                Log(FieldName.Trim & " = " & FieldValue.Trim)
          
                                            Case "1", "2", "3", "4", "5", "6"
                                                Log("  (Numeric score for " & FieldName.Trim & ")")
              
                                            Case "F"
                                                Log("  (No good at " & FieldName.Trim & ")")
          
                                        End Select
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Makumbi

Well-Known Member
Licensed User
there are no keys with that names in the json!
B4X:
[{"ACCOUNT":"05-00005","Name":"DDAMULIRA GEORGE","HISP":"","GPPoints":"F","PhyPoints":"","GeogPoints":"","EconPointst":"B","LitPoints":"","IREPoints":"","LugPoints":"","artpoints":"","FoodPoints":"","TDPoints":"","GermanPoints":"","WoodPoints":"","ArabPoints":"","EnterprPoints":null,"SubMathPoints":"F","CompPOINTS":"F","Principle":5,"Subsidiary":0,"TotalPoints":5}]

If they are no keys as you have suggested then which code can i use to extract only A,B,C,D,E,O,F from that list please help
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
B is in the Key EconPointst
F is GPPoints
there may be other fields with F. It should be easy to iterate through all Keys to find out.
......

You have the jsonparser code in #5. Just use the right keynames....

It is mandatory for you to understand how Collections work.
 
Last edited:
Upvote 0
Top