Attributes
- Companion
- trait
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
JsonDecoder.type
Members list
Value members
Concrete methods
Decodes every element of an already-extracted array, failing on the first element that will not decode.
Decodes every element of an already-extracted array, failing on the first element that will not decode.
Failing rather than dropping is deliberate: a listing that silently discarded a malformed element would under-report, and a caller cannot tell an under-report from a short page.
Attributes
Summons the decoder for A.
Summons the decoder for A.
Attributes
A decoder for a top-level array of objects, which is what most Forgejo list endpoints return.
A decoder for a top-level array of objects, which is what most Forgejo list endpoints return.
An element that is not an object fails the whole page, naming its position — a listing that silently dropped a malformed element would under-report, which is worse than failing.
Attributes
A decoder for a type assembled from the fields of one JSON object.
A decoder for a type assembled from the fields of one JSON object.
build must be total — every accessor on JsonFields answers rather than fails, so it can be. The one thing this decoder rejects is a document that is not an object at all: an array where an object was expected, or the bare literal null. That is a structural mismatch rather than a missing field, and it is worth failing on, because it means the endpoint returned something other than what it documents.
Value parameters
- build
-
assembles the value from the object's fields
Attributes
Givens
Givens
A JSON boolean.
A JSON boolean.
Attributes
A JSON object, as a map from field name to value, for a caller decoding a payload whose keys are data rather than a schema — an EditorConfig, say.
A JSON object, as a map from field name to value, for a caller decoding a payload whose keys are data rather than a schema — an EditorConfig, say.
This is the one place in the library that pays for a map. JsonFields reads named fields straight out of the vector the parser built; a caller who does not know the names has to enumerate them, and a map is the shape that caller wants. Anything with a fixed set of fields should use JsonFields.reader instead.
Attributes
A decoder that hands the parsed document over untouched, for the few payloads whose shape is not fixed.
A decoder that hands the parsed document over untouched, for the few payloads whose shape is not fixed.
Attributes
A JSON number, truncated toward zero.
A JSON number, truncated toward zero.
The two number cases are named rather than matched through JsonValue.Num, whose extractor would build a BigDecimal for the JsonValue.Int64 case that this decoder would then throw away — which is the cost the two cases exist to avoid.
Attributes
A JSON string.
A JSON string.
Strict about the JSON kind, unlike the previous library, which coerced a number into a string so that {"name": 7} decoded as "7". Nothing in this library wanted that, and a silent coercion at the boundary is how a wrong field reaches the domain looking right.
Attributes
Every Forgejo list endpoint answers a top-level array, so a decoder for one element gives a decoder for a page.
Every Forgejo list endpoint answers a top-level array, so a decoder for one element gives a decoder for a page.
A derivation-based library supplies this for free; here it is one line, and it is the line that keeps every Json.decoder[Vector[SomeDto]] call site working without each listing declaring its own.