encoder topic
The encoder will generate formatted JSON Strings.
Encode a JsonObject with .stringify, and it will be formatted using standardJsonFormatting.
final object = JsonObject.elements([
const JsonString(key: "foo", data: "hello"),
const JsonBoolean(key: "isOk", data: true),
const JsonArray<dynamic>(key: "random", data: [1,0,33]),
]);
// when:
final json = object.stringify;
// then:
expect(json, """
{
"foo" : "hello",
"isOk" : true,
"random" : [
1,
0,
33
]
}""");
Encode a JsonObject with .stringifyWithFormatting, and it will be formatted using custom formatting. Use standardJsonFormatting.copyWith to use the standardJsonFormatting as base and only alter what you require.
// given:
final object = JsonObject.elements([
const JsonString(key: "foo", data: "hello"),
const JsonBoolean(key: "isOk", data: true),
const JsonArray<dynamic>(key: "random", data: [1,0,33]),
]);
// when:
final json = object.stringifyWithFormatting(
standardJsonFormatting.copyWith(
indentationSize: JsonIndentationSize.doubleSpace,
colonPadding: 20,
)
);
// then:
expect(json, """
{
"foo" : "hello",
"isOk" : true,
"random" : [
1,
0,
33
]
}""");
Classes
-
JsonArray<
T> ast decoder encoder - A JSON element containing an Array value.
-
JsonArray<
T> ast decoder encoder - A JSON element containing an Array value.
-
JsonArray<
T> ast decoder encoder - A JSON element containing an Array value.
-
JsonArrayOrNull<
T> ast decoder encoder - A JSON element containing an Array value or null.
-
JsonArrayOrNull<
T> ast decoder encoder - A JSON element containing an Array value or null.
-
JsonArrayOrNull<
T> ast decoder encoder - A JSON element containing an Array value or null.
- JsonBoolean ast decoder encoder
- A JSON element containing a bool value.
- JsonBoolean ast decoder encoder
- A JSON element containing a bool value.
- JsonBoolean ast decoder encoder
- A JSON element containing a bool value.
- JsonBooleanOrNull ast decoder encoder
- A JSON element containing a bool value or null.
- JsonBooleanOrNull ast decoder encoder
- A JSON element containing a bool value or null.
- JsonBooleanOrNull ast decoder encoder
- A JSON element containing a bool value or null.
-
JsonDecode<
T, R> decoder encoder - Decode a JsonNode to a non-standard dart type.
-
JsonDecode<
T, R> decoder encoder - Decode a JsonNode to a non-standard dart type.
-
JsonDecode<
T, R> decoder encoder - Decode a JsonNode to a non-standard dart type.
-
JsonEncode<
T> decoder encoder - Encode a (non-standard) dart type to a JsonNode.
-
JsonEncode<
T> decoder encoder - Encode a (non-standard) dart type to a JsonNode.
-
JsonEncode<
T> decoder encoder - Encode a (non-standard) dart type to a JsonNode.
- JsonFloatingNumber ast decoder encoder
- A JSON element containing a double value.
- JsonFloatingNumber ast decoder encoder
- A JSON element containing a double value.
- JsonFloatingNumber ast decoder encoder
- A JSON element containing a double value.
- JsonFloatingNumberOrNull ast decoder encoder
- A JSON element containing a double value or null.
- JsonFloatingNumberOrNull ast decoder encoder
- A JSON element containing a double value or null.
- JsonFloatingNumberOrNull ast decoder encoder
- A JSON element containing a double value or null.
- JsonFormattingOptions encoder
- Options to configure JSON formatting.
- JsonFormattingOptions encoder
- Options to configure JSON formatting.
- JsonFormattingOptions encoder
- Options to configure JSON formatting.
- JsonIntegerNumber ast decoder encoder
- A JSON element containing an int value.
- JsonIntegerNumber ast decoder encoder
- A JSON element containing an int value.
- JsonIntegerNumber ast decoder encoder
- A JSON element containing an int value.
- JsonIntegerNumberOrNull ast decoder encoder
- A JSON element containing an int value or null.
- JsonIntegerNumberOrNull ast decoder encoder
- A JSON element containing an int value or null.
- JsonIntegerNumberOrNull ast decoder encoder
- A JSON element containing an int value or null.
- JsonMissing ast decoder encoder
- A JSON element containing a null value and key.
- JsonMissing ast decoder encoder
- A JSON element containing a null value and key.
- JsonMissing ast decoder encoder
- A JSON element containing a null value and key.
-
JsonNode<
T> ast decoder encoder -
A single JSON node representation consisting of
a String key and
T
data. -
JsonNode<
T> ast decoder encoder -
A single JSON node representation consisting of
a String key and
T
data. -
JsonNode<
T> ast decoder encoder -
A single JSON node representation consisting of
a String key and
T
data. - JsonNull ast decoder encoder
- A JSON element containing a null value.
- JsonNull ast decoder encoder
- A JSON element containing a null value.
- JsonNull ast decoder encoder
- A JSON element containing a null value.
- JsonObject ast decoder encoder
- JSON Object (Map) element.
- JsonObject ast decoder encoder
- JSON Object (Map) element.
- JsonObject ast decoder encoder
- JSON Object (Map) element.
- JsonObjectOrNull ast decoder encoder
- JSON Object (Map) element.
- JsonObjectOrNull ast decoder encoder
- JSON Object (Map) element.
- JsonObjectOrNull ast decoder encoder
- JSON Object (Map) element.
- JsonString ast decoder encoder
- A JSON element containing a String value.
- JsonString ast decoder encoder
- A JSON element containing a String value.
- JsonString ast decoder encoder
- A JSON element containing a String value.
- JsonStringOrNull ast decoder encoder
- A JSON element containing a String or null value.
- JsonStringOrNull ast decoder encoder
- A JSON element containing a String or null value.
- JsonStringOrNull ast decoder encoder
- A JSON element containing a String or null value.
- JsonValue decoder encoder
- Set value of field with value of JsonNode with name.
- JsonValue decoder encoder
- Set value of field with value of JsonNode with name.
- JsonValue decoder encoder
- Set value of field with value of JsonNode with name.
Extensions
- JsonFormatter on String encoder
- Utilities to format a JSON String,
- JsonFormatter on String encoder
- Utilities to format a JSON String,
- JsonFormatter on String encoder
- Utilities to format a JSON String,
- JsonFormattingOptionsBuilder on JsonFormattingOptions encoder
- Helper to customize JsonFormattingOptions.
- JsonFormattingOptionsBuilder on JsonFormattingOptions encoder
- Helper to customize JsonFormattingOptions.
- JsonFormattingOptionsBuilder on JsonFormattingOptions encoder
- Helper to customize JsonFormattingOptions.
Constants
- squint → const _Squint decoder encoder
- All classes annotated with @squint will be processed by the squint library.
- squint → const _Squint decoder encoder
- All classes annotated with @squint will be processed by the squint library.
- squint → const _Squint decoder encoder
- All classes annotated with @squint will be processed by the squint library.
- standardJsonFormatting → const JsonFormattingOptions encoder
- Default JSON formatting options.
- standardJsonFormatting → const JsonFormattingOptions encoder
- Default JSON formatting options.
- standardJsonFormatting → const JsonFormattingOptions encoder
- Default JSON formatting options.
Functions
-
maybeAddQuotes(
dynamic value) → dynamic encoder - Return a quoted String value for JSON if the current value is a String.
-
maybeAddQuotes(
dynamic value) → dynamic encoder - Return a quoted String value for JSON if the current value is a String.
-
maybeAddQuotes(
dynamic value) → dynamic encoder - Return a quoted String value for JSON if the current value is a String.
Enums
- JsonIndentationSize encoder
- Length of indentation per level.
- JsonIndentationSize encoder
- Length of indentation per level.
- JsonIndentationSize encoder
- Length of indentation per level.