json5hs: Serialising to and from JSON5

[ bsd3, data, json5, library, text, web ] [ Propose Tags ]

The JSON5 Data Interchange Format (JSON5) is a superset of JSON that aims to alleviate some of the limitations of JSON by expanding its syntax to include some productions from ECMAScript 5.1.

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

[Skip to Readme]
Versions [faq],,,
Dependencies array, base, bytestring, containers, mtl, pretty, syb (>=0.3.3), text [details]
License BSD-3-Clause
Copyright 2019 Yang X. Nan
Author Yang X. Nan
Maintainer sakamitz@yahoo.co.jp
Category Web, Text, JSON5
Source repo head: git clone https://github.com/sakamitz/json5hs.git
Uploaded by sakamitz at Fri Jul 26 07:32:03 UTC 2019
Distributions NixOS:
Downloads 272 total (104 in the last 30 days)
Rating 1.75 (votes: 1) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2019-07-26 [all 1 reports]


[Index] [Quick Jump]



Use the new split base package.


Add support for using pretty printing combinators.


Add support for generic encoder.


Encode Haskell maps as JSON dicts


Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info


Maintainer's Corner

For package maintainers and hackage trustees

Readme for json5hs-

[back to package description]
<div align="center"> <h1>json5hs: Serialising to and from JSON5</h1> <p> <a href="https://hackage.haskell.org/package/json5hs"><img src="https://img.shields.io/hackage/v/json5hs?color=blue" alt="Hackage"></a> <a href="https://matrix.hackage.haskell.org/#/package/json5hs"><img src="https://img.shields.io/badge/Hackage%20CI-avaliable-brightgreen" alt="Build"></a> </p> </div>

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


ghci> import qualified Text.JSON5 as J
ghci> J.encode [("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]}