jsonDecodeBytes static method
dynamic
jsonDecodeBytes(})
Decodes JSON directly from raw bytes (List<int>) — no String
conversion involved, so this is the direct binary-in counterpart to
jsonEncodeBytes. This is exactly what jsonDecode does internally
when given a List<int>; use this version when you always have bytes
and want a signature that says so. See jsonDecode for reviver and
options.
Implementation
static dynamic jsonDecodeBytes(
List<int> bytes, {
Object? Function(Object? key, Object? value)? reviver,
JsonDecodeOptions? options,
}) {
final parser = _JsonParser(bytes, options, reviver);
final value = parser.parseValue();
parser.skipWhitespace();
if (!parser.isAtEnd) {
throw CoreErrors.invalidOperationArguments(
"jsonDecodeBytes",
reason: 'Invalid json binary. Unexpected trailing character',
);
}
return reviver == null ? value : reviver(null, value);
}