Spanish Se puede hacer dos Json en un formulario ?

ebqlabs

Active Member
Licensed User
Hola tengo una duda:

realizo una consulta en json y todo bien ejemplo (un resumen):

B4X:
#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: false
#End Region

Sub Process_Globals
  
End Sub

Sub Globals
    Dim h As HttpJob
    Dim json As JSONParser
    Private ListView1 As ListView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    ListView1.Initialize("ListView1")
    Activity.AddView(ListView1,0,10%y,100%x,90%y)
  
    h.initialize("json", Me)
    h.Download2("DIRECCION WEB SERVICE"))
End Sub

Sub Activity_Resume

End Sub

Sub JobDone(job As HttpJob)
    If job.Success Then
        json.Initialize(job.GetString)
        CargarDatos
    Else
        Msgbox(job.ErrorMessage, "Error")
    End If
End Sub

Sub CargarDatos
    Dim m As Map
    m=json.NextObject 
    Dim data As List

    data=m.Get("data")
        ListView1.Clear
        For i=0 To data.Size-1
            m=data.Get(i)
            ListView1.AddTwoLines(m.Get("tmp_rut_pac"), m.Get("tmp_nom_pac"))
        Next
End Sub

En CargarDatos llamo a la función en donde desplegó el resultado

Mi pregunta.

Como puedo realizar dos o mas h.Download2("URL")) ? con link diferente? Se puede realizar mas de un json en un mismo formulario ?

Saludos
 
Last edited:

eurojam

Well-Known Member
Licensed User
Longtime User
Hola buenos,
algo como eso?
B4X:
#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: false
#End Region

Sub Process_Globals
 
End Sub

Sub Globals
    Dim h1, h2 As HttpJob

    Private ListView1 As ListView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    ListView1.Initialize("ListView1")
    Activity.AddView(ListView1,0,10%y,100%x,90%y)
 
    h1.initialize("json1", Me)
    h1.Download2("DIRECCION WEB SERVICE"))

    h2.initialize("json2", Me)
    h2.Download2("DIRECCION WEB SERVICE 2"))   
End Sub

Sub Activity_Resume

End Sub

Sub JobDone(job As HttpJob)
    Dim json As JSONParser
    Dim m As Map
        
    If job.Success Then
        json.Initialize(job.GetString)       
        m=json.NextObject
        Select job.JobName
        Case "json1"

           CargarDatos(m, 1)           
        Case "json2"
           CargarDatos(m, 2)           
        End Select

    Else
        Msgbox(job.ErrorMessage, "Error")
    End If
End Sub

Sub CargarDatos (m As Map, typ As Int)

    Dim data As List
    data=m.Get("data")
    If typ = 1 Then
        ListView1.Clear
        For i=0 To data.Size-1
            m=data.Get(i)
            ListView1.AddTwoLines(m.Get("tmp_rut_pac"), m.Get("tmp_nom_pac"))
        Next
    else if typ = 2 Then
        'hacer algo
    End If            
End Sub
 
Top