aeson-warning-parser-0.1.1: Library providing JSON parser that warns about unexpected fields in objects.

Safe Haskell | None
Language | Haskell2010

Data.Aeson.WarningParser

Synopsis

- type WarningParser a = WriterT WarningParserMonoid Parser a
- data JSONWarning
  - = JSONUnrecognizedFields String [Text]
  - | JSONGeneralWarning !Text
- data WithJSONWarnings a = WithJSONWarnings a [JSONWarning]
- withObjectWarnings :: String -> (Object -> WarningParser a) -> Value -> Parser (WithJSONWarnings a)
- jsonSubWarnings :: WarningParser (WithJSONWarnings a) -> WarningParser a
- jsonSubWarningsT :: Traversable t => WarningParser (t (WithJSONWarnings a)) -> WarningParser (t a)
- jsonSubWarningsTT :: (Traversable t, Traversable u) => WarningParser (u (t (WithJSONWarnings a))) -> WarningParser (u (t a))
- logJSONWarnings :: (MonadReader env m, HasLogFunc env, HasCallStack, MonadIO m) => FilePath -> [JSONWarning] -> m ()
- noJSONWarnings :: a -> WithJSONWarnings a
- tellJSONField :: Text -> WarningParser ()
- unWarningParser :: WarningParser a -> Parser a
- (.:) :: FromJSON a => Object -> Text -> Parser a
- (.:?) :: FromJSON a => Object -> Text -> Parser (Maybe a)
- (..:) :: FromJSON a => Object -> Text -> WarningParser a
- (...:) :: FromJSON a => Object -> [Text] -> WarningParser a
- (..:?) :: FromJSON a => Object -> Text -> WarningParser (Maybe a)
- (...:?) :: FromJSON a => Object -> [Text] -> WarningParser (Maybe a)
- (..!=) :: WarningParser (Maybe a) -> a -> WarningParser a

# Documentation

type WarningParser a = WriterT WarningParserMonoid Parser a Source #

A JSON parser that warns about unexpected fields in objects.

data JSONWarning Source #

Warning output from `WarningParser`.

Constructors

JSONUnrecognizedFields String [Text] |
JSONGeneralWarning !Text |

#### Instances

Instances details

IsString JSONWarning Source # |
Instance details Defined in Data.Aeson.WarningParser Methods fromString :: String -> JSONWarning Source #
Show JSONWarning Source # |
Instance details Defined in Data.Aeson.WarningParser Methods showsPrec :: Int -> JSONWarning -> ShowS Source # show :: JSONWarning -> String Source # showList :: [JSONWarning] -> ShowS Source #
Eq JSONWarning Source # |
Instance details Defined in Data.Aeson.WarningParser Methods (==) :: JSONWarning -> JSONWarning -> Bool Source # (/=) :: JSONWarning -> JSONWarning -> Bool Source #
Display JSONWarning Source # |
Instance details Defined in Data.Aeson.WarningParser Methods display :: JSONWarning -> Utf8Builder Source # textDisplay :: JSONWarning -> Text Source #

data WithJSONWarnings a Source #

Constructors

WithJSONWarnings a [JSONWarning] |

#### Instances

Instances details

Functor WithJSONWarnings Source # |
Instance details Defined in Data.Aeson.WarningParser Methods fmap :: (a -> b) -> WithJSONWarnings a -> WithJSONWarnings b Source # (<$) :: a -> WithJSONWarnings b -> WithJSONWarnings a Source #
FromJSON (WithJSONWarnings StylesUpdate) Source # |
Instance details Defined in Data.Aeson.WarningParser Methods parseJSON :: Value -> Parser (WithJSONWarnings StylesUpdate) Source # parseJSONList :: Value -> Parser [WithJSONWarnings StylesUpdate] Source # omittedField :: Maybe (WithJSONWarnings StylesUpdate) Source #
Monoid a => Monoid (WithJSONWarnings a) Source # |
Instance details Defined in Data.Aeson.WarningParser Methods mempty :: WithJSONWarnings a Source # mappend :: WithJSONWarnings a -> WithJSONWarnings a -> WithJSONWarnings a Source # mconcat :: [WithJSONWarnings a] -> WithJSONWarnings a Source #
Monoid a => Semigroup (WithJSONWarnings a) Source # |
Instance details Defined in Data.Aeson.WarningParser Methods (<>) :: WithJSONWarnings a -> WithJSONWarnings a -> WithJSONWarnings a Source # sconcat :: NonEmpty (WithJSONWarnings a) -> WithJSONWarnings a Source # stimes :: Integral b => b -> WithJSONWarnings a -> WithJSONWarnings a Source #
Generic (WithJSONWarnings a) Source # |

Instance details

Defined in Data.Aeson.WarningParser

Associated Types

type Rep (WithJSONWarnings a) |

Instance details

Defined in Data.Aeson.WarningParser

type Rep (WithJSONWarnings a) = D1 ('MetaData "WithJSONWarnings" "Data.Aeson.WarningParser" "aeson-warning-parser-0.1.1-7l002Aeur0WHPunk2muEz9" 'False) (C1 ('MetaCons "WithJSONWarnings" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [JSONWarning])))

Methods

from :: WithJSONWarnings a -> Rep (WithJSONWarnings a) x Source #

to :: Rep (WithJSONWarnings a) x -> WithJSONWarnings a Source #

Show a => Show (WithJSONWarnings a) Source # |
Instance details Defined in Data.Aeson.WarningParser Methods showsPrec :: Int -> WithJSONWarnings a -> ShowS Source # show :: WithJSONWarnings a -> String Source # showList :: [WithJSONWarnings a] -> ShowS Source #
Eq a => Eq (WithJSONWarnings a) Source # |
Instance details Defined in Data.Aeson.WarningParser Methods (==) :: WithJSONWarnings a -> WithJSONWarnings a -> Bool Source # (/=) :: WithJSONWarnings a -> WithJSONWarnings a -> Bool Source #
type Rep (WithJSONWarnings a) Source # |

Instance details

Defined in Data.Aeson.WarningParser

type Rep (WithJSONWarnings a) = D1 ('MetaData "WithJSONWarnings" "Data.Aeson.WarningParser" "aeson-warning-parser-0.1.1-7l002Aeur0WHPunk2muEz9" 'False) (C1 ('MetaCons "WithJSONWarnings" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [JSONWarning])))

withObjectWarnings :: String -> (Object -> WarningParser a) -> Value -> Parser (WithJSONWarnings a) Source #

`WarningParser` version of `withObject`.

jsonSubWarnings :: WarningParser (WithJSONWarnings a) -> WarningParser a Source #

Handle warnings in a sub-object.

jsonSubWarningsT :: Traversable t => WarningParser (t (WithJSONWarnings a)) -> WarningParser (t a) Source #

Handle warnings in a `Traversable` of sub-objects.

jsonSubWarningsTT :: (Traversable t, Traversable u) => WarningParser (u (t (WithJSONWarnings a))) -> WarningParser (u (t a)) Source #

Handle warnings in a `Maybe Traversable` of sub-objects.

logJSONWarnings :: (MonadReader env m, HasLogFunc env, HasCallStack, MonadIO m) => FilePath -> [JSONWarning] -> m () Source #

Log JSON warnings.

noJSONWarnings :: a -> WithJSONWarnings a Source #

tellJSONField :: Text -> WarningParser () Source #

Tell the warning parser about an expected field, so it doesn't warn about it.

unWarningParser :: WarningParser a -> Parser a Source #

Convert a `WarningParser` to a `Parser`.

(.:) :: FromJSON a => Object -> Text -> Parser a Source #

Extends the `.:` warning to include the field name that failed to parse.

(.:?) :: FromJSON a => Object -> Text -> Parser (Maybe a) Source #

Extends the `.:?` warning to include the field name that failed to parse.

(..:) :: FromJSON a => Object -> Text -> WarningParser a Source #

`WarningParser` version of `.:`.

(...:) :: FromJSON a => Object -> [Text] -> WarningParser a Source #

Synonym version of `..:`.

(..:?) :: FromJSON a => Object -> Text -> WarningParser (Maybe a) Source #

`WarningParser` version of `.:?`.

(...:?) :: FromJSON a => Object -> [Text] -> WarningParser (Maybe a) Source #

Synonym version of `..:?`.

(..!=) :: WarningParser (Maybe a) -> a -> WarningParser a Source #

`WarningParser` version of `.!=`.