hermes-json-0.3.0.0: Fast JSON decoding via simdjson C++ bindings
Safe HaskellSafe-Inferred
LanguageHaskell2010
Extensions
  • Cpp
  • BangPatterns
  • OverloadedStrings
  • MultiWayIf

Data.Hermes.Decoder.Value

Synopsis

Documentation

atKey :: Text -> (Value -> Decoder a) -> Object -> Decoder a Source #

Find an object field by key, where an exception is thrown if the key is missing.

atKeyOptional :: Text -> (Value -> Decoder a) -> Object -> Decoder (Maybe a) Source #

Find an object field by key, where Nothing is returned if the key is missing.

atKeyStrict :: Text -> (Value -> Decoder a) -> Object -> Decoder a Source #

Uses find_field, which means if you access a field out-of-order this will throw an exception. It also cannot support optional fields.

atPointer :: Text -> (Value -> Decoder a) -> Decoder a Source #

Decode a value at the particular JSON pointer following RFC 6901. Be careful where you use this because it rewinds the document on each successive call.

bool :: Value -> Decoder Bool Source #

Parse a JSON boolean into a Haskell Bool.

char :: Value -> Decoder Char Source #

Parse only a single character.

double :: Value -> Decoder Double Source #

Parse a JSON number into a Haskell Double.

int :: Value -> Decoder Int Source #

Parse a JSON number into a signed Haskell Int.

list :: (Value -> Decoder a) -> Value -> Decoder [a] Source #

Parse a homogenous JSON array into a Haskell list.

nullable :: (Value -> Decoder a) -> Value -> Decoder (Maybe a) Source #

Transforms a parser to return Nothing when the value is null.

objectAsKeyValues Source #

Arguments

:: (Text -> Decoder k)

Parses a Text key in the Decoder monad. JSON keys are always text.

-> (Value -> Decoder v)

Decoder for the field value.

-> Value 
-> Decoder [(k, v)] 

Parse an object into a homogenous list of key-value tuples.

scientific :: Value -> Decoder Scientific Source #

Parse a Scientific from a Value.

string :: Value -> Decoder String Source #

Parse a JSON string into a Haskell String. For best performance you should use text instead.

text :: Value -> Decoder Text Source #

Parse a JSON string into Haskell Text.

listOfDouble :: Value -> Decoder [Double] Source #

Is more efficient by looping in C++ instead of Haskell.

listOfInt :: Value -> Decoder [Int] Source #

Is more efficient by looping in C++ instead of Haskell.

isNull :: Value -> Decoder Bool Source #

Returns True if the Value is null.

withArray :: (Array -> Decoder a) -> Value -> Decoder a Source #

Helper to work with an Array parsed from a Value.

withBool :: (Bool -> Decoder a) -> Value -> Decoder a Source #

Helper to work with a Bool parsed from a Value.

withDocumentValue :: (Value -> Decoder a) -> InputBuffer -> Decoder a Source #

Parse the given input into a document iterator, get its Value, which is either a JSON object or an array, and run the given action on that Value.

withDouble :: (Double -> Decoder a) -> Value -> Decoder a Source #

Helper to work with a Double parsed from a Value.

withInt :: (Int -> Decoder a) -> Value -> Decoder a Source #

Helper to work with an Int parsed from a Value.

withObject :: (Object -> Decoder a) -> Value -> Decoder a Source #

Helper to work with an Object parsed from a Value.

withRawByteString :: (ByteString -> Decoder a) -> Value -> Decoder a Source #

Helper to work with the raw ByteString of the JSON token parsed from the given Value.

withString :: (String -> Decoder a) -> Value -> Decoder a Source #

Helper to work with a String parsed from a Value.

withText :: (Text -> Decoder a) -> Value -> Decoder a Source #

Helper to work with a Text parsed from a Value.