Dart json字符串转换问题
数据[i][“标题”]= {varent_pos:1,varent_ct:0,title:Aashirvaad Atta,多颗粒 邮袋,图像列表:[],变量id:null,id:43469930505} 但它显示“该字符串看起来不像Json” {varent_pos:1,varent_ct:0,title:Aashirvaad Atta,多颗粒 邮袋,图像列表:[],变量id:null,id:43469930505}Dart json字符串转换问题,dart,flutter,flutter-dependencies,Dart,Flutter,Flutter Dependencies,数据[i][“标题”]= {varent_pos:1,varent_ct:0,title:Aashirvaad Atta,多颗粒 邮袋,图像列表:[],变量id:null,id:43469930505} 但它显示“该字符串看起来不像Json” {varent_pos:1,varent_ct:0,title:Aashirvaad Atta,多颗粒 邮袋,图像列表:[],变量id:null,id:43469930505} 首先试着打印数据[i]['title']的内容,以确保它是一个字符串并且看起来
首先试着打印数据[i]['title']的内容,以确保它是一个字符串并且看起来有效 之后,您可以尝试通过该linter运行JSON
最后一个但不是列表尝试在catch语句中打印实际的异常,可能它包含了更多有用的信息。我明白了,事实上数据[I]['title']的内容不是字符串,而是一个映射。你不需要解码,它已经解码了。
try {
final parsed = json.decode(data[i]['title']);
} on FormatException catch (e) {
print("That string didn't look like Json.");
} on NoSuchMethodError catch (e) {
print('That string was null!');
}"
print(data[i]['title']);