whatsNext method

  1. @override
DecodingType whatsNext()
override

Returns the actual or preferred DecodingType of the encoded data.

Self-describing formats may return a DecodingType that indicates the type of the encoded data, or the preferred way of decoding it.

Non-self-describing formats may only return DecodingType.unknown for all types. In this case, the Decodable implementation must try the appropriate decoding method based on the expected type.

Implementation

@override
DecodingType whatsNext() {
  skipWhitespace();
  return switch (buffer[_offset]) {
    tokenDoubleQuote => DecodingType.string,
    tokenT || tokenF => DecodingType.bool,
    tokenN => DecodingType.nil,
    tokenLBrace => DecodingType.keyed,
    tokenLBracket => DecodingType.iterated,
    _ => DecodingType.num,
  };
}