JsonExtractable<T> class final

Decodes a JSON object body into T.

deserialize is the free function a Deserialize derive generates, so a model written for Dust needs nothing extra:

const createTodo = JsonExtractable<CreateTodo>(CreateTodo.deserialize);

Rejects with 415 for a non-JSON content-type, 400 for malformed syntax, and 422 when the JSON parses but deserialize cannot build a T from it.

Implemented types
Available extensions

Constructors

JsonExtractable(T deserialize(Map<String, Object?> json), {int limit = defaultBodyLimit})
Decodes the body with deserialize.
const

Properties

deserialize → T Function(Map<String, Object?> json)
Builds the value from a decoded JSON object.
final
hashCode int
The hash code for this object.
no setterinherited
limit int
The maximum body size, in bytes.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

extract(Request request) Future<Result<T, Rejection>>
Produces the value, or the rejection that stops the handler.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
require(Request request) Future<T>

Available on FromRequestParts<T>, provided by the RequireExtraction extension

Extracts the value, throwing the Rejection when extraction fails.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited