Answers for "how to convert string to json list flutter"

5

flutter json to list

List to JSON: 
_______________________________________________________________________________
List<String> fruits = ['Apple', 'Banana', 'Orange', 'Strawberry'];
String jsonFruits = jsonEncode(fruits);

________________________________________________________________________________
JSON to List:
________________________________________________________________________________
You need to convert each item individually

	var json = jsonEncode(jsonFruits.map((e) => e.toJson()).toList());

or pass an toEncodable function

	var json = jsonEncode(jsonFruits, toEncodable: (e) => e.toJsonAttr());
Posted by: Guest on May-20-2021
2

flutter convert json string to json

flutter convert json string to json
----------------------
var x1 = '[{"id": "1"}]';
List<dynamic> x2 = jsonDecode(x1);
print(x2[0]);
Posted by: Guest on May-13-2021

Code answers related to "how to convert string to json list flutter"

Code answers related to "Dart"

Browse Popular Code Answers by Language