JSON
- Package
- purescript-json
- Repository
- garyb/purescript-json
#fromBoolean Source
fromBoolean :: Boolean -> JSONConverts a Boolean into JSON.
#fromNumber Source
fromNumber :: Number -> JSONConverts a Number into JSON.
The PureScript Number type admits infinities and a NaN value which are not allowed in JSON,
so when encountered, this function will treat those values as 0.
#fromNumberWithDefault Source
fromNumberWithDefault :: Int -> Number -> JSONCreates a Number into JSON, using a fallback Int value for cases where the
PureScript number value is not valid for JSON (NaN, infinity).
#fromString Source
fromString :: String -> JSONConverts a String into JSON.
Note: this does not parse a string as a JSON value, it takes a PureScript string and
produces the corresponding JSON value for that string, similar to the other functions like
fromBoolean and fromNumber.
To take a string that contains printed JSON and turn it into a JSON value, see
parse.
#fromJArray Source
fromJArray :: JArray -> JSONConverts a JArray into JSON.
#fromJObject Source
fromJObject :: JObject -> JSONConverts a JObject into JSON.
#case_ Source
case_ :: forall a. (Unit -> a) -> (Boolean -> a) -> (Number -> a) -> (String -> a) -> (JArray -> a) -> (JObject -> a) -> JSON -> aPerforms case analysis on a JSON value.
As the JSON type is not a PureScript sum type, pattern matching cannot be used to
discriminate between the potential varieties of value. This function provides an equivalent
mechanism by accepting functions that deal with each variety, similar to an exaustive case
statement.
The Unit case is for null values.
#printIndented Source
printIndented :: JSON -> StringPrints a JSON value as a "pretty" string with newlines and indentation.