import 'dart:convert';
void main(){
//1.List转为String
var list = <String>['a', 'b'];
String s = JsonEncoder().convert(list);
print(s);
//2.String转回List
List<String> list1 = <String>[];
for (var value in JsonDecoder().convert(s)) {
print(value);
list1.add(value);
};
list1.forEach(print);
}
网友评论