直接上代码:

List responseJson = json.decode(response);
List<CardBean> cardbeanList = responseJson.map((m) => new CardBean.fromJson(m)).toList();
CardBean cardBean = cardbeanList.first;

其中response的格式如下:
[
{ “img”: “images/viio-2”,“price”: 12.0,“title”: “海边码头的爱情主题结婚照拍摄”,“ftitle”: “让大海见证你们的爱情,让幸福记录在码头上”,“num”: 0}
,{ “img”: “images/viio-2”,“price”: 12.0,“title”: “海边码头的爱情主题结婚照拍摄”,“ftitle”: “让大海见证你们的爱情,让幸福记录在码头上”,“num”: 0}
]

注意:response是字符串,而不是JSON对象.

GitHub 加速计划 / js / json
50
5
下载
适用于现代 C++ 的 JSON。
最近提交(Master分支:6 个月前 )
51a77f1d 3 天前
756ca22e 3 天前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐