Created
August 8, 2019 16:17
-
-
Save hectorgool/be6766bedcdd0cc5fedac606179eff58 to your computer and use it in GitHub Desktop.
Raw Json
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() { | |
final rawJson = '{"nombre": "Logan", "poder": "Regeneración"}'; | |
Map parsedJson = json.decode(rawJson); | |
//print(parsedJson); | |
final wolverine = new Heroe.fromJson(parsedJson); | |
print(wolverine.nombre); | |
print(wolverine.poder); | |
} | |
class Heroe { | |
String nombre; | |
String poder; | |
Heroe(this.nombre, this.poder); | |
Heroe.fromJson(Map parsedJson) { | |
nombre = parsedJson['nombre']; | |
poder = parsedJson['poder']; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment