gpt4 book ai didi

Json.decode 在 Flutter 中解析 JSON 时挂起

转载 作者:IT王子 更新时间:2023-10-29 07:04:53 25 4
gpt4 key购买 nike

我的回复正文包含以下数据

[{"AttendanceID":null,"MobilePrefID":"Ab12949","DateTimeInString":"08/01/2019","DateTimeOutString":"08/01/2019","TimeIn": "18:16","TimeOut":"18:18","SignInAddress":null,"SignOutAddress":null}]

解码成JSON的代码如下

var dec = json.decode(resp.body)

但是,该命令卡在这里并且不产生结果。

最佳答案

引用自

"Unexpected Character" on Decoding JSON

并试过你的代码

 JsonCodec codec = new JsonCodec();
try{
String strBody = """[{"AttendanceID":null,"MobilePrefID":"Ab12949","DateTimeInString":"08/01/2019","DateTimeOutString":"08/01/2019","TimeIn":"18:16","TimeOut":"18:18","SignInAddress":null,"SignOutAddress":null}]""";
print(strBody);
var decoded = codec.decode(strBody);
print("Decoded 1: $decoded");
} catch(e) {
print("Error: $e");
}

你会得到结果

关于Json.decode 在 Flutter 中解析 JSON 时挂起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54140738/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com