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

Data.Hermes.Decoder.Value

Synopsis

Documentation

atKey :: Text -> Decoder a -> FieldsDecoder a Source #

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

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

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

atKeyStrict :: Text -> Decoder a -> FieldsDecoder 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 -> 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.

decodeEither (atPointer "/statuses/99" decodeObject) input

bool :: Decoder Bool Source #

Parse a JSON boolean into a Haskell Bool.

char :: Decoder Char Source #

Parse only a single character.

double :: Decoder Double Source #

Parse a JSON number into a Haskell Double.

int :: Decoder Int Source #

Parse a JSON number into a signed Haskell Int.

uint :: Decoder Word Source #

Parse a JSON number into an unsigned Haskell Int (Word).

getType :: Decoder ValueType Source #

Get the simdjson type of the Value.

list :: Decoder a -> Decoder [a] Source #

Parse a homogenous JSON array into a Haskell list.

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

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

object :: FieldsDecoder a -> Decoder a Source #

Enter an Object to begin parsing its fields.

objectAsKeyValues Source #

Arguments

:: (Text -> Decoder k)

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

-> Decoder v

Decoder for the field value.

-> Decoder [(k, v)] 

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

objectAsMap Source #

Arguments

:: Ord k 
=> (Text -> Decoder k)

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

-> Decoder v

Decoder for the field value.

-> Decoder (Map k v) 

Parse an object into a strict Map.

objectAsMapExcluding Source #

Arguments

:: Ord k 
=> [Text]

List of field names to exclude.

-> (Text -> Decoder k)

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

-> Decoder v

Decoder for the field value.

-> Decoder (Map k v) 

Parse an object into a strict Map. Skips any fields in the given list, which adds a slight performance penalty.

parseScientific :: Text -> Decoder Scientific Source #

Parse a Scientific from UTF-8 text.

scientific :: Decoder Scientific Source #

Parse a Scientific from a Value.

string :: Decoder String Source #

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

text :: Decoder Text Source #

Parse a JSON string into Haskell Text.

listOfDouble :: Decoder [Double] Source #

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

listOfInt :: Decoder [Int] Source #

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

isNull :: Decoder Bool Source #

Returns True if the Value is null.

vector :: Vector v a => Decoder a -> Decoder (v a) Source #

Parse a homogenous JSON array into a generic Vector.

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

Helper to work with a Bool parsed from a Value.

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

Helper to work with a Double parsed from a Value.

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

Helper to work with an Int parsed from a Value.

withObjectAsMap Source #

Arguments

:: Ord k 
=> (Text -> Decoder k)

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

-> Decoder v

Decoder for the field value.

-> (Map k v -> Decoder a) 
-> Decoder a 

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

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

withRawText :: (Text -> Decoder a) -> Decoder a Source #

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

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

Helper to work with a String parsed from a Value.

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

Helper to work with a Text parsed from a Value.

withVector :: Vector v a => Decoder a -> (v a -> Decoder a) -> Decoder a Source #