JsonBytesEncoder class
Encodes a value to JSON as UTF-8 bytes, in one pass, into one buffer.
It gives the same bytes and the same errors as JsonUtf8Encoder. That
encoder writes each byte through a bounds check into small chunks, then
joins the chunks. This one makes room once per value, writes numbers
with no String in between, and copies the result one time. It writes
plain text 8 bytes at a time, and it keeps the bytes of the keys it
wrote, because an app writes the same few keys again and again.
One encoder keeps its buffer between calls, so use one per isolate.
- Implemented types
Constructors
- JsonBytesEncoder(dynamic _toEncodable(dynamic object), {JsonObjectWriter? writerOf(Object)?})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isLent → bool
-
true while a result of convertView is lent
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
boolean(
bool? value) → void -
Writes
true,falseornull.override -
convert(
Object? value) → Uint8List -
valueas JSON bytes. -
convertView(
Object? value) → Uint8List -
valueas JSON bytes, with no copy: the result is a part of the buffer of this encoder. The buffer is then lent to the caller. -
dateTime(
DateTime? value) → void -
The same text as
toIso8601String(), with noStringin between:2024-05-17T03:04:05.006Z. The 3 digits of the microseconds are there only when they are not 0, and theZonly for a UTC time.override -
endObject(
) → void -
Ends the object:
}.override -
giveBack(
List< int> view) → void -
Gives back the buffer that convertView lent with
view. Another list (eg. a copy) does nothing. -
integer(
int? value) → void -
Writes a whole number, or
null.override -
key(
String key) → void -
A comma goes before each key but the first. The byte before the
first key is the
{of startObject: no value ends with that byte.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
run(
JsonRun run) → void -
Writes whole words: the bytes after the run are written over by the
next write.
Most runs are a key with its comma: 1 or 2 words, with no loop.
override
-
startObject(
) → void -
Starts an object:
{.override -
string(
String? value) → void -
Writes a text value, or
null.override -
toString(
) → String -
A string representation of this object.
inherited
-
value(
Object? value) → void -
Writes any other value, with the rules of
JSON.bytes(): adouble, abool,null, aList, aMap, a JsonWritable or an object withtoJson().override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited