Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data JsonValue
- = JsonString Text
- | JsonNumber Double
- | JsonObject [(Text, JsonValue)]
- | JsonArray [JsonValue]
- | JsonBool Bool
- | JsonNull
- class JsonValueAt a where
- jsonValueAt :: a -> Either DecodeError JsonValue
Documentation
Traditional JSON type.
This type has the a constructor per JSON data type as is typical for JSON in most libraries.
See jsonValueAt
on how to parse JSON text into this datatype.
Although Haskell data types are lazy by default, you will not get a fully lazy data structure when parsing to this type because there is no way to express parsing errors in this datatype.
For a data type that gives you lazier behaviour, see other alternatives such as
JsonPartialValue
or LightJson
.
JsonString Text | |
JsonNumber Double | |
JsonObject [(Text, JsonValue)] | |
JsonArray [JsonValue] | |
JsonBool Bool | |
JsonNull |
class JsonValueAt a where Source #
jsonValueAt :: a -> Either DecodeError JsonValue Source #
Get a JSON value from another type
The hw-json
library does not do full JSON validation for efficiency reasons, but parsing can
fail if the JSON is malformed. When parsing fails, then Left
will be returned.
If Right
is returned then that means there are no parsing failures, which implies "knowing"
that there parsing failures in the entire document, which implies that pattern matching on
Right
evaluates the entire document.
This limits the laziness of the JSON parsing. For lazier alternatives, see
jsonPartialJsonValueAt
or lightJsonAt
.
Instances
JsonValueAt JsonIndex Source # | |
Defined in HaskellWorks.Data.Json.Value |