我的回复正文包含以下数据
[{"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)
但是,命令停留在此处,不会产生结果。
答案 0 :(得分:0)
获得参考
"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");
}
您将获得结果