Android Question JSON Object expected. when NextObject is called

rkmoray

Active Member
Licensed User
Longtime User
It's a good thing I have lots of hair, because I am ripping them out strand by strand.
I changed my webservice to send me back a json string instead of XML.
My code is very simple
B4X:
    Dim JSON As JSONParser
        Dim Map1 As Map
        JSON.Initialize(WS_url)
        Map1 = JSON.NextObject
        Dim m As Map
My data string looks like the
B4X:
[{"Title":"TARGETED","ReceiptTicketItemIndex":166661,"SerialNumber":1,"PerformanceIndex":11206,"TicketCategoryIndex":769,"ReceiptTicketItemIndex1":166661,"ReceiptItemIndex":307226,"CurtainTime":"\/Date(1475197200000)\/","FilmIndex":673,"AuditoriumIndex":19,"TicketCatName":"Senior 62+","TicketCatTypeIndex":4,"AudName":"AUD 7","ScheduleDate":"\/Date(1475128800000)\/","Swapped":null,"SwapReserved":null,"SeatRowNumber":null,"SeatName":null,"RowName":null,"RowScreenToProjection":null,"RowQty":null}]
My error message is on the "NextObject" line, and it states java.lang.RuntimeException: JSON Object expected.
 

DonManfred

Expert
Licensed User
Longtime User
B4X:
Dim parser As JSONParser
parser.Initialize(<text>) ' Put your text here......
Dim root As List = parser.NextArray
For Each colroot As Map In root
 Dim TicketCatName As String = colroot.Get("TicketCatName")
 Dim ReceiptTicketItemIndex As Int = colroot.Get("ReceiptTicketItemIndex")
 Dim FilmIndex As Int = colroot.Get("FilmIndex")
 Dim TicketCategoryIndex As Int = colroot.Get("TicketCategoryIndex")
 Dim Title As String = colroot.Get("Title")
 Dim ReceiptItemIndex As Int = colroot.Get("ReceiptItemIndex")
 Dim ScheduleDate As String = colroot.Get("ScheduleDate")
 Dim TicketCatTypeIndex As Int = colroot.Get("TicketCatTypeIndex")
 Dim PerformanceIndex As Int = colroot.Get("PerformanceIndex")
 Dim SeatRowNumber As String = colroot.Get("SeatRowNumber")
 Dim AuditoriumIndex As Int = colroot.Get("AuditoriumIndex")
 Dim CurtainTime As String = colroot.Get("CurtainTime")
 Dim SerialNumber As Int = colroot.Get("SerialNumber")
 Dim SeatName As String = colroot.Get("SeatName")
 Dim RowScreenToProjection As String = colroot.Get("RowScreenToProjection")
 Dim ReceiptTicketItemIndex1 As Int = colroot.Get("ReceiptTicketItemIndex1")
 Dim AudName As String = colroot.Get("AudName")
 Dim RowQty As String = colroot.Get("RowQty")
 Dim Swapped As String = colroot.Get("Swapped")
 Dim SwapReserved As String = colroot.Get("SwapReserved")
 Dim RowName As String = colroot.Get("RowName")
Next
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…