This library contains the definition of a data type to represent JSON values.
data JValue
Abstract representation of a JSON value.
Constructors:
JBool
:: Bool -> JValue
JNull
:: JValue
JString
:: String -> JValue
JInt
:: Int -> JValue
JNumber
:: Float -> JValue
JArray
:: [JValue] -> JValue
JObject
:: JObject -> JValue
Known instances:
newtype JObject
A JSON object is just some representation of a mapping from names (strings) to JSON values. It is an abstract type (rather than an explicit list) to ensure that there are no duplicate entries.
Known instances:
fromJObject
:: JObject -> [(String, JValue)]
Extracts the list of name / JSON value pairs from a JSON object.
toJObject
:: [(String, JValue)] -> JObject
Transforms a list of name / JSON value pairs into a JSON object. Pairs with duplicated names are deleted to ensure that the JSON object is a map from names to values.
lookupName
:: String -> JObject -> Maybe JValue
Retrieves the JSON value with a given name from a JSON object if it exists.
insertField
:: String -> JValue -> JObject -> JObject
Inserts a name / JSON value pair in a JSON object. If the name already exists, the existing value is overwritten.
true
orfalse
in JSON)