1

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!

2 Answers 2

3

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 ints

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! this is working. But I have another problem parsing nested arrays, if you could check this question of mine HERE
0
import 'dart:convert';
void main() {
  var x = "[ 5, \n 10, \n15\n, 20]";
  var b = jsonDecode(x);
  print(b[3]); //prints 20

}

2 Comments

Thanks Sir!.. I will try this.
Hi sir can you check THIS out too? it's the same problem but parsing nested json arrays into model class.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.