decodeJson method

  1. @override
Future decodeJson({
  1. Object? reviver(
    1. Object? key,
    2. Object? value
    )?,
})
override

Reads and decodes content body as a JSON object, returned in a future.

The result is an object tree as parsed by the standard json.decode() of the dart:convert package.

An optional reviver function is applied when decoding json string data. See JsonCodec of the dart:convert package for more information.

Throws ClientException if content body cannot be decoded as JSON.

Implementation

@override
Future<dynamic> decodeJson({
  Object? Function(Object? key, Object? value)? reviver,
}) async {
  try {
    return json.decode(
      await file.readAsString(encoding: encoding),
      reviver: reviver,
    );
  } on Exception catch (e) {
    throw ClientException.decodingJsonFailed(e);
  }
}