| CARVIEW |
Select Language
HTTP/1.1 200 OK
Connection: keep-alive
Server: nginx/1.24.0 (Ubuntu)
Content-Type: text/html; charset=utf-8
Cache-Control: public, max-age=300
Content-Encoding: gzip
Via: 1.1 varnish, 1.1 varnish
Accept-Ranges: bytes
Age: 0
Date: Sun, 18 Jan 2026 14:49:08 GMT
X-Served-By: cache-dfw-kdfw8210043-DFW, cache-bom-vanm7210078-BOM
X-Cache: MISS, MISS
X-Cache-Hits: 0, 0
X-Timer: S1768747748.927390,VS0,VE857
Vary: Accept, Accept-Encoding
transfer-encoding: chunked
roundtrip-aeson: Un-/parse JSON with roundtrip invertible syntax definitions.
roundtrip-aeson: Un-/parse JSON with roundtrip invertible syntax definitions.
Downloads
- roundtrip-aeson-0.3.0.2.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
| Versions [RSS] | 0.2.0.0, 0.2.0.1, 0.2.0.2, 0.3.0.2 |
|---|---|
| Change log | ChangeLog |
| Dependencies | aeson, base (>=4.7 && <5), bytestring, containers (>=0.5 && <0.6), lens, lens-aeson, roundtrip (>=0.2 && <0.3), scientific, text (>=1.2 && <1.3), unordered-containers, vector [details] |
| License | BSD-3-Clause |
| Copyright | Copyright 2014-2015 Anchor Systems and others. |
| Author | Thomas Sutton <me@thomas-sutton.id.au>, Christian Marie <christian@ponies.io> |
| Maintainer | Christian Marie |
| Uploaded | by ChristianMarie at 2018-10-14T07:55:31Z |
| Category | Data |
| Home page | https://github.com/christian-marie/roundtrip-aeson |
| Source repo | head: git clone https://github.com/christian-marie/roundtrip-aeson |
| Distributions | |
| Reverse Dependencies | 2 direct, 0 indirect [details] |
| Downloads | 2489 total (12 in the last 30 days) |
| Rating | (no votes yet) [estimated by Bayesian average] |
| Your Rating |
|
| Status | Docs not available [build log] All reported builds failed as of 2018-10-14 [all 3 reports] |
Readme for roundtrip-aeson-0.3.0.2
[back to package description]Roundtrip Aeson
roundtrip allows you to write invertible syntax descriptions -- or, to put it another way, a parser and pretty printer combined -- for String or XML data. This package extends this to support constructing and destructing JSON documents.
Example
Using roundtrip-aeson is relatively straightforward:
-
Define your data type;
-
Define partial isomorphisms for the constructors (probably using the template haskell);
-
Describe the syntax of its JSON representation; and
-
Use that representation to build and parse JSON.
import Data.Aeson.RoundTrip
data Invoice
= Unpaid Bool Integer Bool
| Paid Double
deriving (Show)
defineIsomorphisms ''Invoice
invoiceSyntax :: JsonSyntax s => s Invoice
invoiceSyntax =
unpaid
<$> jsonField "overdue" jsonBool
<*> jsonField "total" jsonIntegral
<*> jsonField "warned" jsonBool
<|> paid
<$> jsonField "total" jsonRealFrac
main :: IO ()
main = do
-- Build a JSON representation.
let Right x = runBuilder invoiceSyntax $ Unpaid False 40 [False]
L.putStrLn $ encode x
-- Parse a JSON representation.
print $ runParser invoiceSyntax x
See tests/demo.hs for the complete source of this example.