Mohamed Shaheen
Mohamed Shaheen

Reputation: 663

Json String to Map<> or List

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?

Upvotes: 1

Views: 81

Answers (1)

Günter Zöchbauer
Günter Zöchbauer

Reputation: 657068

You need to JSON-decode the value first

import 'dart:convert';

final decoded = jsonDecode(json);
print(decoded[0]['name']); // just one example

Upvotes: 3

Related Questions