runtime library

Runtime support library imported by the generated *.easy.dart files.

This is not intended to be imported directly by application code — use package:dart_easy_json/easy_json.dart for the annotations and EasyIssue. It is public only so that generated code does not need to reach into src/.

Classes

EasyIssue
A single problem found while parsing or validating a JSON payload.

Functions

asBool(Object? v, {bool fallback = false}) → bool
asBoolOrNull(Object? v) → bool?
asDouble(Object? v, {double fallback = 0.0}) → double
asDoubleOrNull(Object? v) → double?
asInt(Object? v, {int fallback = 0}) → int
asIntOrNull(Object? v) → int?
Coerções básicas usadas no SAFE e no fast parse. Todas são "permissivas" e nunca lançam exceção.
asString(Object? v, {String fallback = ''}) → String
asStringOrNull(Object? v) → String?
coerceKeyIntOrNull(Object? k) → int?
Map key coercion
coerceKeyString(Object? k) → String
decodeBigInt(Object? v) → BigInt?
String decimal, ou um número inteiro.
decodeBytes(Object? v) → Uint8List?
String em Base64.
decodeDateTime(Object? v) → DateTime?
String ISO-8601, ou milissegundos desde a epoch.
decodeDuration(Object? v) → Duration?
Número de microssegundos (ou String numérica).
decodeNum(Object? v) → num?
num, ou uma String numérica ("3.5").
decodeUri(Object? v) → Uri?
String com uma URI válida.
dedupeIssues(void onIssue(EasyIssue)?) → void Function(EasyIssue)?
Envolve onIssue para descartar issues repetidas (mesmo path e code).
enumByNameOr<T extends Enum>(List<T> values, Object? v, T fallback) → T
Enums
mapListOrNull<T>(Object? raw, ListItemMapper<T> f) → List<T>?
mapMapOrNull<K, V>(Object? raw, MapEntryMapper<K, V> f) → Map<K, V>?
mapSetOrNull<T>(Object? raw, SetItemMapper<T> f) → Set<T>?
parseDateTime(Object? v, {DateTime? fallback}) → DateTime
parseDateTimeOrNull(Object? v) → DateTime?
DateTime helpers
writePath(Map<String, dynamic> json, List<String> path, Object? value) → void
Escreve value em json no caminho aninhado path (ex.: ['shipping', 'address', 'city']), criando os mapas intermediários. Usado pelo toJson gerado para campos com @EasyPath, para que a saída tenha o mesmo formato aninhado que o fromJson lê.

Typedefs

ListItemMapper<T> = T Function(int index, Object? raw)
Iteradores com índice (para List/Set/Map) — economizam código gerado
MapEntryMapper<K, V> = MapEntry<K, V>? Function(Object key, Object? value)
SetItemMapper<T> = T Function(int index, Object? raw)

Exceptions / Errors

EasyValidationException
Thrown by the generated fromJson of a class annotated with @EasyJson(strict: true) when the payload fails validation.