Android Question nested json catch

joaomoraes83

Member
Licensed User
Hey,
I need to get the references via json from the url below (12 first) and later include them for capture in another json creating a chain of 12 references per type. With the code below I can capture the 12 references but I'm having difficulty how to include them in a new capture in json at url = "https://tabela-fipe-api.herokuapp.com/v1/carros/marcas/6/modelos / 44 / model_year / 1995-1? Reference = & codref1 "
Can you help me?
B4X:
ProgressDialogShow2("Carregando Dados...",False)
    Dim GetAddressJob As HttpJob
    Dim url As String
    GetAddressJob.Initialize("GetAddress", Me)
    url="https://tabela-fipe-api.herokuapp.com/v1/referencias"
    GetAddressJob.Download(url)
    Wait For (GetAddressJob) JobDone(GetAddressJob As HttpJob)
    ProgressDialogHide
    If GetAddressJob.Success Then

        Dim parser As JSONParser
        parser.Initialize(GetAddressJob.GetString)
        Dim colroot As Map
        Dim codref1, codref2, codref3, codref4, codref5, codref6, codref7, codref8, codref9, codref10, codref11, codref12  As Int
        Dim mesref1, mesref2, mesref3, mesref4, mesref5, mesref6, mesref7, mesref8, mesref9, mesref10, mesref11, mesref12 As String
        Dim root As List = parser.NextArray
        
        colroot=root.Get(0)
        codref1=colroot.Get("Codigo")
        mesref1=colroot.Get("Mes")
        
        colroot=root.Get(1)
        codref2=colroot.Get("Codigo")
        mesref2=colroot.Get("Mes")

        colroot=root.Get(2)
        codref3=colroot.Get("Codigo")
        mesref3=colroot.Get("Mes")

        colroot=root.Get(3)
        codref4=colroot.Get("Codigo")
        mesref4=colroot.Get("Mes")
        
        colroot=root.Get(4)
        codref5=colroot.Get("Codigo")
        mesref5=colroot.Get("Mes")

        colroot=root.Get(5)
        codref6=colroot.Get("Codigo")
        mesref6=colroot.Get("Mes")
        
        colroot=root.Get(6)
        codref7=colroot.Get("Codigo")
        mesref7=colroot.Get("Mes")

        colroot=root.Get(7)
        codref8=colroot.Get("Codigo")
        mesref8=colroot.Get("Mes")
        
        colroot=root.Get(8)
        codref9=colroot.Get("Codigo")
        mesref9=colroot.Get("Mes")

        colroot=root.Get(9)
        codref10=colroot.Get("Codigo")
        mesref10=colroot.Get("Mes")
        
        colroot=root.Get(10)
        codref11=colroot.Get("Codigo")
        mesref11=colroot.Get("Mes")

        colroot=root.Get(11)
        codref12=colroot.Get("Codigo")
        mesref12=colroot.Get("Mes")
        
        ProgressDialogHide
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Else
        MsgboxAsync("Erro de conexão! Verifique sua conexão com a internet e tente novamente.","FIPE Fácil")
        ProgressDialogHide
    End If
 

DonManfred

Expert
Licensed User
Longtime User
B4X:
Dim parser As JSONParser
parser.Initialize(jsonhere)
Dim root As List = parser.NextArray
For Each colroot As Map In root
 Dim Label As String = colroot.Get("Label")
 Dim Value As Int = colroot.Get("Value")
Next
 
Upvote 0
Top