Dart flutter: jsonDecode() parse a list of string to List<dynamic>
. e.g.
{
name: 'John',
hobbies: ['run', 'swim']
}
The hobbies is parsed to be a List<dynamic>
with 2 items (of type String). should it be a List<String>
?
Dart flutter: jsonDecode() parse a list of string to List<dynamic>
. e.g.
{
name: 'John',
hobbies: ['run', 'swim']
}
The hobbies is parsed to be a List<dynamic>
with 2 items (of type String). should it be a List<String>
?
2
Answers
You can turn it into the right type like this:
You can create a class like this:
Now you can map the json to this class: