Portability | portable |
---|---|
Stability | experimental |
Maintainer | Julian Fleischer <julian.fleischer@fu-berlin.de> |
Safe Haskell | None |
Text.DeadSimpleJSON
Description
A simple approach for parsing JSON.
To read JSON data use read
. To print JSON data use show
:
let jsonData = read "[1,2,4,8,16]" :: JSON putStrLn $ show jsonData
You can query json data using ?
. Querying implies conversion,
therefor you may need to specify the result type:
let jsonData = read "{\"seven\": 7, \"nine\": [1,2,4,8,16]}" print $ (jsonData ? "nine[3]" :: Int)
For tighter control use parse
. A more convenient way for
creating JSON objects in source code or querying JSON data,
is using Template Haskell. See Text.SimpleJSON.TH
.
The recommended way for importing this module is importing it qualified, like so:
import qualified Text.SimpleJSON as JSON import Text.SimpleJSON (JSON)
Parsing strings
parse' :: String -> Maybe ValueSource
Parses a top-level JSON object, returning Just a Value or Nothing.
Basic data types
A JSON value.
Constructors
String String | A JSON String, represented as ordinary Haskell String. |
Number !Integer !Integer | A JSON Number, represented by two |
Object (Map String Value) | A JSON Object, represented as |
Array (Vector Value) | A JSON Array, represented as |
True | True. |
False | False. |
Null | Null (void, unit, |