Unable to locate how to use fromJson in readme
dhirajhimani opened this issue · comments
Dhiraj Himani commented
` static final Map<String, dynamic> userMeResponse = jsonDecode(''' {
"me": {
"id": "some-id",
"firstName": "erst",
"lastName": "zwei"
}
}''';
`
How to read the Map<String, dynamic> as from Json.
final crimson = Crimson(utf8.encode(userMeResponse));
print (crimson.read());
final xyz = crimson.readXYZ();
Please could you provide a sample where Map<String, dynamic> is being read and consumed by Crimson
arcas0803 commented
I discover how to do it. You need to write your own method to get Object from Map<String, dynamic>
factory Mascota.fromBytes(Uint8List json) => _$MascotaFromBytes(json);
factory Mascota.frmJson(Map<String, dynamic> json) => Mascota.fromBytes(
Uint8List.fromList(
jsonEncode(json).codeUnits,
),
);