Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/lupino/fay-simplejson

SimpleJSON library for Fay
https://github.com/lupino/fay-simplejson

Last synced: about 1 month ago
JSON representation

SimpleJSON library for Fay

Awesome Lists containing this project

README

        

Fay SimpleJSON
==============

SimpleJSON library for Fay.

```haskell
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RebindableSyntax #-}

-- Compile with: fay --package fay-simplejson test.hs --pretty

module Test (main) where

import Data.Text (Text, fromString)
import Prelude
import SimpleJSON

data Test = Test { xKey :: Text, xValue :: Text }

decoder :: Parser
decoder = withDecoder "Test" [ rawRule "xKey" "key",
rawRule "xValue" "value" ]

encoder :: Parser
encoder = withEncoder [ rawRule "key" "xKey",
rawRule "value" "xValue" ]

main :: Fay ()
main = do
let test = decode "{\"key\": \"test_key\", \"value\": \"test_value\"}" decoder :: Test
print test
print $ encode test encoder
```

Usage
-----

Install:
```bash
cabal install fay-simplejson
```

Compile your file:

```bash
fay --package fay-simplejson MyFile.hs
```