JSON-Combinator-0.0.1: A combinator library on top of Text.JSON

Text.JSONb.Combinator

Description

Combinators for Text.JSONb data types. http://hackage.haskell.org/package/JSONb

Synopsis

Documentation

type JArray = [JSON]Source

The type of JSON arrays.

type JObject = Trie JSONSource

The type of JSON objects.

jNot :: JSON -> JSONSource

Inverts the JSON value if it is a boolean.

withNumber :: (Rational -> Rational) -> JSON -> JSONSource

Runs the given function if the JSON value is a number.

withString :: (ByteString -> ByteString) -> JSON -> JSONSource

Runs the given function if the JSON value is a string.

withArray :: (JArray -> JArray) -> JSON -> JSONSource

Runs the given function if the JSON value is an array.

withObject :: (JObject -> JObject) -> JSON -> JSONSource

Runs the given function if the JSON value is an object.

withObjectFields :: (ByteString -> ByteString) -> JSON -> JSONSource

Runs the given function on the fields if the JSON value is an object.

withObjectValues :: (JSON -> JSON) -> JSON -> JSONSource

Runs the given function on the field values if the JSON value is an object.

(->:) :: (ByteString, JSON) -> JSON -> JSONSource

Prepends the given association if the JSON is an object.

(-->>:) :: JSON -> JSON -> JSONSource

Prepends the given value if the JSON is an array.

jZero :: JSONSource

A JSON number with the value zero.

jEmptyString :: JSONSource

A JSON string with a value of empty.

jEmptyArray :: JSONSource

A JSON array with a value of empty.

jEmptyObject :: JSONSource

A JSON object with a value of empty.

jTrue :: JSONSource

A JSON boolean with a value of true.

jFalse :: JSONSource

A JSON boolean with a value of false.

jSingleArray :: JSON -> JSONSource

Returns a JSON array value with the given single value.

jSingleObject :: ByteString -> JSON -> JSONSource

Returns a JSON object value with the given single association value.

getBool :: JSON -> Maybe BoolSource

Returns the potential boolean value of a JSON value.

getNumber :: JSON -> Maybe RationalSource

Returns the potential number value of a JSON value.

getString :: JSON -> Maybe ByteStringSource

Returns the potential string value of a JSON value.

getArray :: JSON -> Maybe [JSON]Source

Returns the potential array value of a JSON value.

getObject :: JSON -> Maybe (Trie JSON)Source

Returns the potential object value of a JSON value.

getObjectFields :: JSON -> Maybe [ByteString]Source

Returns the potential object fields of a JSON value.

getObjectValues :: JSON -> Maybe [JSON]Source

Returns the potential object field values of a JSON value.

isBool :: JSON -> BoolSource

Returns whether or not a JSON is a boolean value.

isTrue :: JSON -> BoolSource

Returns whether or not a JSON is a boolean with the value true.

isFalse :: JSON -> BoolSource

Returns whether or not a JSON is a boolean with the value false.

isNumber :: JSON -> BoolSource

Returns whether or not a JSON is a number value.

isString :: JSON -> BoolSource

Returns whether or not a JSON is a string value.

isArray :: JSON -> BoolSource

Returns whether or not a JSON is an array value.

isObject :: JSON -> BoolSource

Returns whether or not a JSON is an object value.

numberOr :: Rational -> JSON -> RationalSource

Returns a number value from a JSON value or if it is not a number, returns the given default.

stringOr :: ByteString -> JSON -> ByteStringSource

Returns a string value from a JSON value or if it is not a string, returns the given default.

arrayOr :: JArray -> JSON -> JArraySource

Returns a rational value from a JSON value or if it is not a rational, returns the given default.

objectOr :: Trie JSON -> JSON -> Trie JSONSource

Returns an object value from a JSON value or if it is not an object, returns the given default.

objectFieldsOr :: [ByteString] -> JSON -> [ByteString]Source

Returns an object's fields from a JSON value or if it is not an object, returns the given default.

objectValuesOr :: [JSON] -> JSON -> [JSON]Source

Returns an object's values from a JSON value or if it is not an object, returns the given default.

numberOrZero :: JSON -> RationalSource

Returns a number value from a JSON value or if it is not a number, returns zero.

stringOrEmpty :: JSON -> ByteStringSource

Returns a string value from a JSON value or if it is not a string, returns an empty string.

arrayOrEmpty :: JSON -> JArraySource

Returns an array value from a JSON value or if it is not an array, returns an empty array.

objectOrEmpty :: JSON -> Trie JSONSource

Returns an object value from a JSON value or if it is not an object, returns an empty object.

objectFieldsOrEmpty :: JSON -> [ByteString]Source

Returns an object's fields from a JSON value or if it is not an object, returns no fields.

objectValuesOrEmpty :: JSON -> [JSON]Source

Returns an object's values from a JSON value or if it is not an object, returns no values.

usingNumber :: a -> (Rational -> a) -> JSON -> aSource

Runs a function on the number of a JSON value or if it is not a number, returns the given default.

usingString :: a -> (ByteString -> a) -> JSON -> aSource

Runs a function on the string of a JSON value or if it is not a string, returns the given default.

usingArray :: a -> ([JSON] -> a) -> JSON -> aSource

Runs a function on the array of a JSON value or if it is not an array, returns the given default.

usingObject :: a -> (Trie JSON -> a) -> JSON -> aSource

Runs a function on the object of a JSON value or if it is not an object, returns the given default.

usingObjectFields :: a -> ([ByteString] -> a) -> JSON -> aSource

Runs a function on the fields of an object of a JSON value or if it is not an object, returns the given default.

usingObjectValues :: a -> ([JSON] -> a) -> JSON -> aSource

Runs a function on the values of an object of a JSON value or if it is not an object, returns the given default.

hasField :: ByteString -> JSON -> BoolSource

Whether or not a JSON value is an object with the given field.

(-?) :: ByteString -> JSON -> BoolSource

Whether or not a JSON value is an object with the given field. An alias for hasField.

field :: ByteString -> JSON -> Maybe JSONSource

Returns the possible value associated with the given field if this is an object.

(-|) :: ByteString -> JSON -> Maybe JSONSource

Returns the possible value associated with the given field if this is an object. An alias for field.

fieldOr :: ByteString -> JSON -> JSON -> JSONSource

Returns the value associated with the given field or if this is not an object or has no associated value, return the given default.

fieldOrNull :: ByteString -> JSON -> JSONSource

Returns the value associated with the given field or if this is not an object or has no associated value, return a JSON null.

fieldOrTrue :: ByteString -> JSON -> JSONSource

Returns the value associated with the given field or if this is not an object or has no associated value, return a JSON true.

fieldOrFalse :: ByteString -> JSON -> JSONSource

Returns the value associated with the given field or if this is not an object or has no associated value, return a JSON false.

fieldOrZero :: ByteString -> JSON -> JSONSource

Returns the value associated with the given field or if this is not an object or has no associated value, return a JSON zero.

fieldOrEmptyString :: ByteString -> JSON -> JSONSource

Returns the value associated with the given field or if this is not an object or has no associated value, return a JSON string that is empty.

fieldOrEmptyArray :: ByteString -> JSON -> JSONSource

Returns the value associated with the given field or if this is not an object or has no associated value, return a JSON array that is empty.

fieldOrEmptyObject :: ByteString -> JSON -> JSONSource

Returns the value associated with the given field or if this is not an object or has no associated value, return a JSON object that is empty.

hasField' :: Foldable t => t ByteString -> JSON -> BoolSource

Traverses down JSON objects with the association fields and returns true if the association graph exists.

(-??) :: Foldable t => t ByteString -> JSON -> BoolSource

Traverses down JSON objects with the association fields and returns true if the association graph exists. An alias for hasField'.

field' :: Foldable t => t ByteString -> JSON -> Maybe JSONSource

Traverses down JSON objects with the association fields and returns the potential value.

(-||) :: Foldable t => t ByteString -> JSON -> Maybe JSONSource

Traverses down JSON objects with the association fields and returns the potential value. An alias for field'.

field'Or :: Foldable t => JSON -> t ByteString -> JSON -> JSONSource

Traverses down JSON objects with the association fields and returns the potential value or the given default.

field'OrNull :: Foldable t => t ByteString -> JSON -> JSONSource

Traverses down JSON objects with the association fields and returns the potential value or a JSON null.

field'OrTrue :: Foldable t => t ByteString -> JSON -> JSONSource

Traverses down JSON objects with the association fields and returns the potential value or a JSON true.

field'OrFalse :: Foldable t => t ByteString -> JSON -> JSONSource

Traverses down JSON objects with the association fields and returns the potential value or a JSON false.

field'OrZero :: Foldable t => t ByteString -> JSON -> JSONSource

Traverses down JSON objects with the association fields and returns the potential value or a JSON zero.

field'OrEmptyString :: Foldable t => t ByteString -> JSON -> JSONSource

Traverses down JSON objects with the association fields and returns the potential value or a JSON empty string.

field'OrEmptyArray :: Foldable t => t ByteString -> JSON -> JSONSource

Traverses down JSON objects with the association fields and returns the potential value or a JSON empty array.

field'OrEmptyObject :: Foldable t => t ByteString -> JSON -> JSONSource

Traverses down JSON objects with the association fields and returns the potential value or a JSON empty object.

interactJSON :: (Either String JSON -> JSON) -> IO ()Source

Interacts by parsing the standard input for JSON, passing the result to the given function, then printing the result to standard output.

interactJSON' :: (String -> JSON) -> (JSON -> JSON) -> IO ()Source

Interacts by parsing the standard input for JSON, passing a failed result with a string error message to the given function, or a successful result to the given function, then printing the result to standard output.

withJSON :: (String -> IO ()) -> (JSON -> JSON) -> IO ()Source

Interacts by parsing the standard input for JSON, executing the given function for a failed result with a string error message, or printing a successful result to the given function and passing the result to standard output.

interactJSONFile :: (Either String JSON -> JSON) -> FilePath -> FilePath -> IO ()Source

Interacts by parsing the given file for JSON, passing the result to the given function, then writing the result to the given file.

interactJSONFile' :: (String -> JSON) -> (JSON -> JSON) -> FilePath -> FilePath -> IO ()Source

Interacts by parsing the given file for JSON, passing a failed result with a string error message to the given function, or a successful result to the given function, then writing the result to the given file.

withJSONFile :: (String -> IO ()) -> (JSON -> JSON) -> FilePath -> FilePath -> IO ()Source

Interacts by parsing the given file for JSON, executing the given function for a failed result with a string error message, or printing a successful result to the given function and writing the result to the given file.