Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/lupino/fay-simplejson
- Owner: Lupino
- License: other
- Created: 2016-10-28T03:41:02.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-11-01T07:18:49.000Z (about 8 years ago)
- Last Synced: 2024-04-23T18:15:33.542Z (8 months ago)
- Language: Haskell
- Size: 18.6 KB
- Stars: 2
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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 SimpleJSONdata 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
```