@hackage json5hs0.1.2.1

Serialising to and from JSON5

json5hs: Serialising to and from JSON5

Hackage Build Status


This library provides a parser and pretty printer for converting between Haskell values and JSON5.

Example

ghci> import qualified Text.JSON5 as J
ghci> J.encode [("key1",1),("key2",2)]
"[[\"key1\",1],[\"key2\",2]]"

ghci> import Text.JSON5.String (runGetJSON)
ghci> input <- getLine 
{'singleQuotes': 0xabcde, pos: +3, infnan: +Infinity, escape: "\t\u1234", trailing-comma: ['here',], }
ghci> runGetJSON J.readJSValue input
Right (JSObject (JSONObject {fromJSObject = [("singleQuotes",JSNumber (JSRational (703710 % 1))),("pos",JSNumber (JSRational (3 % 1))),("infnan",JSNumber (JSInfNaN Infinity)),("escape",JSString (JSONString {fromJSString = "\t\4660"})),("trailing-comma",JSArray [JSString (JSONString {fromJSString = "here"})])]}))

ghci> ppJSValue (JSObject (JSONObject [("key1",JSString (JSONString "string")),("key2",JSNumber (JSRational 42)),("key3",JSArray [JSBool True,JSNull])]))
{"key1": "string", "key2": 42, "key3": [true, null]}

  • Installation

  • Dependencies (8)

  • Dependents (0)

  • Package Flags

      split-base
       (on by default)

      Use the new split base package.

      pretty
       (on by default)

      Add support for using pretty printing combinators.

      generic
       (on by default)

      Add support for generic encoder.

      mapdict
       (off by default)

      Encode Haskell maps as JSON dicts