Skip to content
JSON quasiquoter for Haskell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/Data Update GitHub repo Mar 19, 2016
.travis.yml Fix warnings Sep 17, 2014
README.lhs Update README Jun 4, 2014
aeson-qq.cabal Bump version Jun 13, 2017
package.yaml Bump version Jun 13, 2017


aeson-qq: JSON quasiquoter for Haskell

This package exposes the function aesonQQ that compile-time converts a string representation of a JSON value into a Data.Aeson.Value. aesonQQ has the signature

aesonQQ :: QuasiQuoter

and is used like

{-# LANGUAGE QuasiQuotes #-}
import Data.Aeson.QQ
import Data.Aeson (Value)

john :: Value
john = [aesonQQ| {age: 23, name: "John", likes: ["linux", "Haskell"]} |]

The quasiquoter can also interpolate variables like

jane :: Value
jane = [aesonQQ| {age: #{age}, name: #{name}} |]
    age = 23 :: Int
    name = "Jane"

where the function toJSON. will be called on age and name at runtime.

You can also interpolate arbitrary Haskell expressions:

mary :: Value
mary = [aesonQQ| {age: #{succ age}, name: "Mary"} |]
    age = 23 :: Int

If you want to replace the name of the key in a hash you'll use the $-syntax:

joe :: Value
joe = [aesonQQ| {$key: 23, name: "Joe"} |]
    key = "age"
You can’t perform that action at this time.