Skip to content

Instantly share code, notes, and snippets.

@indiealexh
Created December 28, 2021 17:21
Show Gist options
  • Save indiealexh/df318ee6209ef0fed32f06736c5aa40e to your computer and use it in GitHub Desktop.
Save indiealexh/df318ee6209ef0fed32f06736c5aa40e to your computer and use it in GitHub Desktop.
json object of objects to list
import 'dart:convert';
void main() {
String json =
'{"0": {"hello":"world"},"1": {"hello":"dave"},"2": {"hello":"alex"}}';
print(json);
var object = jsonDecode(json);
print(object);
List helloList =
object.entries.map((entry) => Hello(entry.value["hello"])).toList();
print(helloList);
}
class Hello {
String hello;
Hello(String hello) : hello = hello;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment