free-agent
Safe HaskellNone
LanguageGHC2024

Free.Agent.Json

Description

Small helpers over Json for the free-agent wire codecs. These are the shapes that Acp, Gateway, and BusStats need; they are not a general JSON utility library.

Synopsis

Lookup

objLookup :: Text -> Json -> Maybe Json Source #

Look up a key in a JSON object.

arrToList :: Json -> [Json] Source #

Convert a JSON array to a list.

textAt :: Text -> Json -> Maybe Text Source #

Extract a text value from a JSON object field.

numAt :: Text -> Json -> Maybe Scientific Source #

Extract a numeric value from a JSON object field.

boolAt :: Text -> Json -> Maybe Bool Source #

Extract a boolean value from a JSON object field.

intAt :: Text -> Json -> Maybe Int Source #

Extract a bounded integer value from a JSON object field.

Construction

jtext :: Text -> Json Source #

JSON string value.

jnum :: Integral a => a -> Json Source #

JSON number value from an integral literal.

jbool :: Bool -> Json Source #

JSON boolean value.

jobject :: [(Text, Json)] -> Json Source #

JSON object from key/value pairs.

jarray :: [Json] -> Json Source #

JSON array from a list.

Encoding

encodeJsonText :: Json -> Text Source #

Render a Json value to Text.