I can't seems to find a solution to parse a json array without key using Dart language. All i can find is by using Java. I need to parse something like this..
[
5,
10,
15,
20
]
Java solution is from here
Please inform me if I have duplicate question. Thank you!
Just use json.decode
as normal, for example:
List<dynamic> l = json.decode('[5, 10, 15, 20]');
It happens that the members of l
will all be int
s
import 'dart:convert';
void main() {
var x = "[ 5, \n 10, \n15\n, 20]";
var b = jsonDecode(x);
print(b[3]); //prints 20
}
- DartPad Example
- Official docs