Skip to content

Instantly share code, notes, and snippets.

@ueman
Last active January 5, 2022 07:58
Show Gist options
  • Save ueman/9e23d761fa31966f5eb5dfa6676719bd to your computer and use it in GitHub Desktop.
Save ueman/9e23d761fa31966f5eb5dfa6676719bd to your computer and use it in GitHub Desktop.
import 'dart:convert';
void main() {
final dynamic smth = jsonDecode('''
{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
"Acronym": "SGML",
"Abbrev": "ISO 8879:1986",
"GlossDef": {
"para": "A meta-markup language, used to create markup languages such as DocBook.",
"GlossSeeAlso": [
"GML",
"XML"
]
},
"GlossSee": "markup"
}
}
}
},
"GlossSeeAlso": [
"GML",
"XML"
]
}
''');
// maps
print(smth is Map<String, dynamic>);
print(smth['glossary'] is Map<String, dynamic>);
print(smth['glossary']['GlossDiv']['GlossList'] is Map<String, dynamic>);
// lists
print(smth['GlossSeeAlso'] is List<String>);
print(smth['GlossSeeAlso'] is List<dynamic>);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment