0

How can I retrieve all this information from Json and insert it into a ListView on my Flutter app?

"acordos": {
"29": {
    "0": {
        "installment": 0,
        "link": "https://hml.use...",
        "amount": 55.07,
        "amount_paid": 0.0,
        "status": "VEN",
        "due_date": "2021-05-04",
        "receivable_type": "ACO",
        "payment_method": "banking_billet",
        "acordo": "86",
        "created_at": "2021-05-04",
        "updated_at": "2021-05-05"
    },
    "1": {
        "installment": 1,
        "link": "https://hml.use...",
        "amount": 20.62,
        "amount_paid": 20.62,
        "status": "PAG",
        "due_date": "2021-05-04",
        "receivable_type": "ACO",
        "payment_method": "banking_billet",
        "acordo": "86",
        "created_at": "2021-05-04",
        "updated_at": "2021-05-04"
    },
    "2": {
        "installment": 2,
        "link": "https://hml.use...",
        "amount": 20.62,
        "amount_paid": 20.62,
        "status": "PAG",
        "due_date": "2021-05-04",
        "receivable_type": "ACO",
        "payment_method": "banking_billet",
        "acordo": "86",
        "created_at": "2021-05-04",
        "updated_at": "2021-05-04"
    },
    "3": {
        "installment": 3,
        "link": "https://hml.use...",
        "amount": 20.62,
        "amount_paid": 20.62,
        "status": "PAG",
        "due_date": "2021-05-04",
        "receivable_type": "ACO",
        "payment_method": "banking_billet",
        "acordo": "86",
        "created_at": "2021-05-04",
        "updated_at": "2021-05-04"
    }
}

},

I have did it before, but only with json files with "[]" in the objects and I has success but with this kind of Json I can't.

Acorcdev
  • 371
  • 1
  • 3
  • 13
  • Does this answer your question? [How to Parse a JSON Object In Android](https://stackoverflow.com/questions/5566669/how-to-parse-a-json-object-in-android) – Anand Jun 06 '21 at 22:30

2 Answers2

0

There's only one "type" of JSON, and the one you wrote is not correct.

If you want to write correct JSON, there's one simple rule:

"property":value

The value can be an array [], a string "", an integer, etc.

If what you wrote is a "custom structure", then you should write a specific interpreter in order to reach the last element that is a correct written JSON.

The problem is in the last section... It's an array but no [] are defined, so it's not a correct JSON and you cannot use something already existing to read it but you need to iterate through elements by yourself and then at the end you can get a JSON object from the last {}

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Patrick G.
  • 458
  • 5
  • 7
0

The JSON format is wrong, try add {} in the beginning and the end, like

{
    "acordos": {
        "29": {
            "0": {
                "installment": 0,
                "link": "https://hml.use...",
                "amount": 55.07,
                "amount_paid": 0.0,
                "status": "VEN",
                "due_date": "2021-05-04",
                "receivable_type": "ACO",
                "payment_method": "banking_billet",
                "acordo": "86",
                "created_at": "2021-05-04",
                "updated_at": "2021-05-05"
            },
            "1": {
                "installment": 1,
                "link": "https://hml.use...",
                "amount": 20.62,
                "amount_paid": 20.62,
                "status": "PAG",
                "due_date": "2021-05-04",
                "receivable_type": "ACO",
                "payment_method": "banking_billet",
                "acordo": "86",
                "created_at": "2021-05-04",
                "updated_at": "2021-05-04"
            },
            "2": {
                "installment": 2,
                "link": "https://hml.use...",
                "amount": 20.62,
                "amount_paid": 20.62,
                "status": "PAG",
                "due_date": "2021-05-04",
                "receivable_type": "ACO",
                "payment_method": "banking_billet",
                "acordo": "86",
                "created_at": "2021-05-04",
                "updated_at": "2021-05-04"
            },
            "3": {
                "installment": 3,
                "link": "https://hml.use...",
                "amount": 20.62,
                "amount_paid": 20.62,
                "status": "PAG",
                "due_date": "2021-05-04",
                "receivable_type": "ACO",
                "payment_method": "banking_billet",
                "acordo": "86",
                "created_at": "2021-05-04",
                "updated_at": "2021-05-04"
            }
        }
    }
}

Then, you may decode it correctlly

Sam Chan
  • 1,665
  • 4
  • 14