The conversion of Flutter Json to List and Map is very simple. This can be done by using the built-in Json decoder json.decode() in Dart: Convert

Turn Json List

/ / a JSON format String String jsonStr = '[{" name ":" * * "}, {" name ":" bill "}]'. // Convert JSON string to List List List = json.decode(jsonStr); Print (list[0]["name"]);Copy the code

The List to Json

String jsonStringA = json.encode(list);
print(jsonStringA);
Copy the code

Json to turn the Map

// A String in JSON format String jsonStr = '{"name": "wang5 ","address":" Dongcheng District, Beijing "}'; // Convert the JSON String to List Map<String, dynamic> Map = json.decode(jsonStr); Print (${map['name']}'); Print (${map['address']}');Copy the code

The Map to Json

String jsonStringB = json.encode(map);
print(jsonStringB);
Copy the code

Original link, if infringement please contact the author to delete