fay-simplejson: SimpleJSON library for Fay.

[ bsd3, fay, library, web ] [ Propose Tags ]

SimpleJSON library for Fay.


[Skip to Readme]

Modules

[Index]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.1.0, 0.1.3.0
Dependencies fay-base (>=0.18) [details]
License BSD-3-Clause
Copyright Li Meng Jun
Author Li Meng Jun
Maintainer lmjubuntu@gmail.com
Category Web, Fay
Home page https://github.com/Lupino/fay-simplejson
Bug tracker https://github.com/Lupino/fay-simplejson/issues
Source repo head: git clone https://github.com/Lupino/fay-simplejson.git
Uploaded by Lupino at 2016-10-28T05:47:04Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 1420 total (7 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2016-10-29 [all 1 reports]

Readme for fay-simplejson-0.1.1.0

[back to package description]

Fay SimpleJSON

SimpleJSON library for Fay.

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RebindableSyntax  #-}

module Test (main) where

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

data Test = Test { xKey :: Text, xValue :: Text }
instance JSONSetter Test
instance JSONGetter Test

decoder :: Decoder Test
decoder = withDecoder "Test" ["xKey" .> "key", "xValue" .> "value"]

encoder :: Encoder TestJSON
encoder = withEncoder ["key" .< "xKey", "value" .< "xValue"]

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

Usage

Install:

cabal install fay-simplejson

Compile your file:

fay --package fay-simplejson MyFile.hs