simc / crimson

Fast, efficient and easy-to-use JSON parser and serializer for Dart.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to locate how to use fromJson in readme

dhirajhimani opened this issue · comments

` 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

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,
        ),
      );