1

I have a json stored as string like below

String json="[{"name":"a","id",1},{"name":"b","id",2},{"name":"c","id",3}]";

My Question how to encode this to a map or a list to get access to the keys and use the values?

3
  • This is already a list of maps. The type String is invalid. It should be List<Map<String,dynamic>>. Commented Feb 17, 2019 at 13:04
  • check the edit I have it stores as a string Commented Feb 17, 2019 at 13:16
  • That's still invalid ;p because you can't have " inside a string delimited by " without escaping the inner ". Commented Feb 17, 2019 at 13:21

1 Answer 1

3

You need to JSON-decode the value first

import 'dart:convert';

final decoded = jsonDecode(json);
print(decoded[0]['name']); // just one example
Sign up to request clarification or add additional context in comments.

Comments

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.