如何在flutter中将json对象转换为json数组 [英] How to convert json objects to json array in flutter

查看:169
本文介绍了如何在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.

这篇关于如何在flutter中将json对象转换为json数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆