fromJson static method

TupleCodecInterface fromJson(
  1. Map<String, dynamic> json
)
override

Implementation

static TupleCodecInterface fromJson(final Map<String, dynamic> json) {
  if (json['type'] == null || json['id'] == null) {
    throw Exception('Exception as didn\'t found the type for this json: $json');
  }
  final int id = json['id'];
  final Map<String, dynamic> typeObject = json['type'];
  final MapEntry defType = (typeObject['def'] as Map).entries.first;

  return TupleCodecInterface(
    id: id,
    tuple: defType.value.cast<int>(),
    path: typeObject['path']?.cast<String>(),
    docs: typeObject['docs']?.cast<String>(),
  );
}