如何在flutter中将json对象转换为json数组

问题描述:

这是我的json响应数据.我想使用map在listview中显示此数据,但是我不知道如何将对象的对象转换为数据数组.

This is my json response data. I would like to display this data in listview using map but i dont know how to convert the objects of objects to array of data.

  {
        "success": true,
        "data": {
            "addresses": {
                "abc": {
                    "address_id": "121",
                    "firstname": "Demo",
                    "lastname": "User",
                    "company": "Demo Company name",
                    "telephone": "1-541-754-3011",
                    "address_1": "Demo",
                    "address_2": "test address",
                    "postcode": "3333",
                    "city": "Berlin",
                    "zone_id": "1256",
                    "zone": "Berlin",
                    "zone_code": "BER",
                    "country_id": "81",
                    "country": "Germany",
                    "longitude": "",
                    "lattitude": "",
                    "iso_code_2": "DE",
                    "iso_code_3": "DEU",
                    "address_format": "{company}\r\n{firstname} {lastname}\r\n{address_1}\r\n{address_2}\r\n{postcode} {city}\r\n{country}",
                    "custom_field": null
                }
            }
        }
    }

您可以使用 JSON到飞镖工具,可以免费在线获取.

You can use JSON to dart tool, which is available online for free.

将JSON粘贴到左侧面板,然后从右上角选择dart语言,

Paste your JSON to left panel and select dart language from upper right corner,

您将获得dart类代码,在其中可以使用.toMap()和.toJson()之类的方法,

You will get your dart class code, in which you can use methods like .toMap() and .toJson(),

这对于处理巨大的JSON数据非常有帮助.

This can be very helpful for huge JSON data.