Android Question Exception No data with HttpJob

ziz

Member
Hello you all

When requesting to read data from FireBase that does not exist, the application closes and collapses with this line

B4X:
 Dim root As Map = parser.NextObject

Of course, this is normal
Is there a way to avoid this problem ?


B4X:
Public Sub ReadData(LinkSuffix As String, Token As String,RequestTag As String)
    Dim hj As HttpJob
   
   
    hj.Initialize("readdata",Me)
    hj.Tag = RequestTag
    Dim RequestURL As String = BaseURL & LinkSuffix & ".json"
    If Not(Token = "") Then
        RequestURL = RequestURL & "?auth=" & Token
    End If
   
    hj.Download(RequestURL)
  
    Wait For (hj) JobDone(hj As HttpJob)
    
    If hj.Success Then
         
        
        Dim parser As JSONParser
        parser.Initialize(hj.GetString) 
         
        
        Dim root As Map = parser.NextObject
   
   
End Sub
 

Star-Dust

Expert
Licensed User
Longtime User
if the label/tag name is a number it generates this error. the outer braces should be added
B4X:
If hj.Success Then
  If ht.GetString.StartWith("{") then
      Dim gs As String = ht.GetString
  Else
      Dim gs as String = "{" & ht.GetString & "}"
  End If

  Log(gs)
  Dim parser As JSONParser
  parser.Initialize(gs)
End if
 
Last edited:
  • Like
Reactions: ziz
Upvote 0
Top