decode method

DecodeResult<A> decode(
  1. dynamic json
)

Implementation

DecodeResult<A> decode(dynamic json) {
  return key.fold(() => _decodeF(json), (key) {
    if (json is Map<String, dynamic> && !json.containsKey(key)) {
      return left(DecodingError.missingField(key));
    } else if (json is! Map<String, dynamic>) {
      return left(DecodingError("Expected value at field: '$key'"));
    } else {
      return _decodeF(json[key]);
    }
  });
}