且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何用数组数组解析扑扑中的json?

更新时间:2022-01-07 05:30:07

要解析json,您可以使用包dart:convert中的json.decode(jsonString).但是首先,您需要修复格式.

To parse a json you can use json.decode(jsonString) from package dart:convert. But first, you need to fix the format.

在这种情况下,您可以使用例如replaceAll方法添加双引号.

In this case, you could use for example replaceAll method to add the double quotes.

String jsonString = "/*loaded json*/";
jsonString = jsonString.replaceAll('ModuleEId', '"ModuleEId"');

然后

final parsed = json.decode(jsonString);

完整示例: Dartpad