Created
December 28, 2021 17:21
-
-
Save indiealexh/df318ee6209ef0fed32f06736c5aa40e to your computer and use it in GitHub Desktop.
json object of objects to list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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