Extract data from complex JSON

Hello, I have a need in an application to consult an API where my client will enter the document number and this document may be linked to more than one contract and the API returns me a Json with all the contracts and their respective information, I need to take each contract number and play it in a listview.
I managed to do it with clients who have only one contract, but clients who have more than one contract, I still couldn’t understand how to go through the text and get this specific information.

Here is a JSON model:

{
    "msg": "Contrato(s) Localizado(s)",
    "contratos": [
        {
            "cobPermuta": false,
            "contratoCentralSenha": "iumox1010",
            "endereco_complemento": null,
            "popNome": "RIBEIRAO PRETO/SP",
            "contratoStatus": 1,
            "endereco_uf": "SP",
            "servico_plano": "Webnet 50 Megas",
            "endereco_pontoreferencia": null,
            "cobIsento": 0.0,
            "cpfCnpj": "2173617883",
            "endereco_logradouro": "RANGEL PESTANA",
            "contratoStatusModo": 2,
            "telefones": [
                "(16) 9528-23434",
                "(16)3714-1600"
            ],
            "contratoStatusDisplay": " Ativo ",
            "endereco_numero": 257,
            "contratoValorAberto": 0.0,
            "planointernet": "Webnet 50 Megas",
            "servico_login": "pine-gacho",
            "endereco_bairro": "VILA VIRGINIA",
            "emails": [
                "[email protected]"
            ],
            "razaoSocial": "DANILO GUSTAVO DE PAULA",
            "servico_mac": "",
            "contratoTitulosAReceber": 0,
            "popId": 1,
            "endereco_cep": "14030-210",
            "promessasPagamentoMes": 0,
            "endereco_cidade": "RIBEIRAO PRETO",
            "servico_senha": "jolkikju887h",
            "clienteId": 1,
            "contratoId": 10000
        },
        {
            "cobPermuta": false,
            "contratoCentralSenha": "andradas700",
            "endereco_complemento": "",
            "popNome": "RIBEIRAO PRETO/SP",
            "contratoStatus": 1,
            "endereco_uf": "SP",
            "servico_plano": "20_MEGAS",
            "endereco_pontoreferencia": "",
            "cobIsento": 0.0,
            "cpfCnpj": "21187617883",
            "endereco_logradouro": "RANGEL PESTANA",
            "contratoStatusModo": 2,
            "telefones": [
                "(16) 9898-23434",
                "(16)3954-1600"
            ],
            "contratoStatusDisplay": " Ativo ",
            "endereco_numero": 257,
            "contratoValorAberto": 0.0,
            "planointernet": "20_MEGAS",
            "servico_login": "grita_rapuru",
            "endereco_bairro": "VILA VIRGINIA",
            "emails": [
                "[email protected]"
            ],
            "razaoSocial": "DANILO GUSTAVO DE PAULA",
            "servico_mac": "58:10:8C:5D:2C:2A",
            "contratoTitulosAReceber": 0,
            "popId": 1,
            "endereco_cep": "14030-210",
            "promessasPagamentoMes": 0,
            "endereco_cidade": "RIBEIRAO PRETO",
            "servico_senha": "0o9as700",
            "clienteId": 1,
            "contratoId": 10007
        }
    ]
}

Thanks in advance!

Have you tried the dictionary blocks? Also read the documentation on them.

Welcome.

Loop (control / repeat structure) The block is in my answer.

Use
Get Value For Key “contratos”
In dictionary ( your list )
Put in variable ContractNumber
getvalue

foreach3
Do for each in SuaLista

anotherlist
Block add itens to list OutraLista

lookuppairs3
Item. - Block look UP in pairs Key

Set listview elements OutraLista

4 Likes

Thank you very much friend, it worked very well!
Just one more question, how do I concatenate the data from the same as you did, showing in each list item more than one information? I’m attaching my pad, if there is anything I need improvement I would like to know because I started using the platform now … Thanks again for the tips!

1 Like

Use Join and several look up in pairs (each for a “field”) And between each item (as in my example) use " < br > "

P.S.- I like to pass the tips to the developer to use the reasoning
:thumbsup:

Check resolved if the answer was the solution. :+1:t2:

1 Like

Hello, I managed to make the list work and the app is getting cool. But I still have a question, I want that when clicking on an item in the list the app goes to a new screen taking the contract value Id, how can I get that value when clicking on the list? I realized that the list is not a key and value element, how should I proceed? I tried some approaches with dictionary but I couldn’t get the value …
Thanks in advance for any help!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.