| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Ecluse.Core.Json.Lenient
Description
Small lenient-decode primitives shared by every ecosystem's aeson wire decoders. Pure aeson support with no registry or package concept, so it sits beside the bounded selective-decode engine in Ecluse.Core.Json.Selective rather than in any one ecosystem's wire module:
lenientOptionalreads an optional field, degrading a present-but-undecodable value toNothingrather than failing the whole decode, so one poisoned advisory value cannot deny a whole document.typeMismatchOneOffails a permissive string-or-object decoder with a descriptive message that names the accepted shapes and the JSON kind actually found.
Synopsis
- lenientOptional :: FromJSON a => Object -> Key -> Parser (Maybe a)
- typeMismatchOneOf :: String -> Value -> Parser a
Documentation
lenientOptional :: FromJSON a => Object -> Key -> Parser (Maybe a) Source #
Decode an optional field leniently: an absent, null, or
present-but-undecodable value all yield Nothing. Where (.:?) fails the whole
decode on a present-but-wrong value, this degrades a hostile value (wrong-typed,
fractional, or outside the target's range) to Nothing instead. Reserved for
advisory fields, so one poisoned value cannot deny the whole document; a
load-bearing field keeps (.:?)/(.:).