jsonDecode flutter code example
Example 1: read json file flutter
Future<String>_loadFromAsset() async {
return await rootBundle.loadString("assets/quiz.json");
}
Future parseJson() async {
String jsonString = await _loadFromAsset();
final jsonResponse = jsonDecode(jsonString);
}
Example 2: flutter access json object inside object
myJson = {
"label": "This is a string",
"value": {
"address": "This is a string",
"country": "This is a string"
}
}
var decodedJson = json.decode(myJson);
var jsonValue = json.decode(decodedJson['value']);
print(jsonValue['address']);