-
Notifications
You must be signed in to change notification settings - Fork 0
/
Data-Aeson-TH.html
80 lines (79 loc) · 23.2 KB
/
Data-Aeson-TH.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Data.Aeson.TH</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_Data-Aeson-TH.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Data-Aeson-TH.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">aeson-0.10.0.0: Fast JSON parsing and encoding</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Copyright</th><td>(c) 2011-2015 Bryan O'Sullivan
(c) 2011 MailRank, Inc.</td></tr><tr><th>License</th><td>Apache</td></tr><tr><th>Stability</th><td>experimental</td></tr><tr><th>Portability</th><td>portable</td></tr><tr><th>Safe Haskell</th><td>None</td></tr><tr><th>Language</th><td>Haskell98</td></tr></table><p class="caption">Data.Aeson.TH</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Encoding configuration</a></li><li><a href="#g:2">FromJSON and ToJSON derivation</a></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>Functions to mechanically derive <code><a href="Data-Aeson-Types.html#t:ToJSON">ToJSON</a></code> and <code><a href="Data-Aeson-Types.html#t:FromJSON">FromJSON</a></code> instances. Note that
you need to enable the <code>TemplateHaskell</code> language extension in order to use this
module.</p><p>An example shows how instances are generated for arbitrary data types. First we
define a data type:</p><pre>data D a = Nullary
| Unary Int
| Product String Char a
| Record { testOne :: Double
, testTwo :: Bool
, testThree :: D a
} deriving Eq
</pre><p>Next we derive the necessary instances. Note that we make use of the
feature to change record field names. In this case we drop the first 4
characters of every field name. We also modify constructor names by
lower-casing them:</p><pre>$(<code><a href="Data-Aeson-TH.html#v:deriveJSON">deriveJSON</a></code> <code><a href="Data-Aeson-TH.html#v:defaultOptions">defaultOptions</a></code>{<code><a href="Data-Aeson-TH.html#v:fieldLabelModifier">fieldLabelModifier</a></code> = <code>drop</code> 4, <code><a href="Data-Aeson-TH.html#v:constructorTagModifier">constructorTagModifier</a></code> = map toLower} ''D)
</pre><p>Now we can use the newly created instances.</p><pre>d :: D <code><a href="../base-4.8.1.0/Data-Int.html#t:Int">Int</a></code>
d = Record { testOne = 3.14159
, testTwo = <code><a href="../base-4.8.1.0/Data-Bool.html#v:True">True</a></code>
, testThree = Product "test" 'A' 123
}
</pre><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>fromJSON (toJSON d) == Success d
</code></strong>> True
</pre><p>This also works for data family instances, but instead of passing in the data
family name (with double quotes), we pass in a data family instance
constructor (with a single quote):</p><pre>data family DF a
data instance DF Int = DF1 Int
| DF2 Int Int
deriving Eq
$(<code><a href="Data-Aeson-TH.html#v:deriveJSON">deriveJSON</a></code> <code><a href="Data-Aeson-TH.html#v:defaultOptions">defaultOptions</a></code> 'DF1)
-- Alternatively, one could pass 'DF2 instead
</pre><p>Please note that you can derive instances for tuples using the following syntax:</p><pre>-- FromJSON and ToJSON instances for 4-tuples.
$(<code><a href="Data-Aeson-TH.html#v:deriveJSON">deriveJSON</a></code> <code><a href="Data-Aeson-TH.html#v:defaultOptions">defaultOptions</a></code> ''(,,,))
</pre></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><span class="keyword">data</span> <a href="#t:Options">Options</a> = <a href="#v:Options">Options</a> {<ul class="subs"><li><a href="#v:fieldLabelModifier">fieldLabelModifier</a> :: <a href="../base-4.8.1.0/Data-String.html#t:String">String</a> -> <a href="../base-4.8.1.0/Data-String.html#t:String">String</a></li><li><a href="#v:constructorTagModifier">constructorTagModifier</a> :: <a href="../base-4.8.1.0/Data-String.html#t:String">String</a> -> <a href="../base-4.8.1.0/Data-String.html#t:String">String</a></li><li><a href="#v:allNullaryToStringTag">allNullaryToStringTag</a> :: <a href="../base-4.8.1.0/Data-Bool.html#t:Bool">Bool</a></li><li><a href="#v:omitNothingFields">omitNothingFields</a> :: <a href="../base-4.8.1.0/Data-Bool.html#t:Bool">Bool</a></li><li><a href="#v:sumEncoding">sumEncoding</a> :: <a href="Data-Aeson-TH.html#t:SumEncoding">SumEncoding</a></li><li><a href="#v:unwrapUnaryRecords">unwrapUnaryRecords</a> :: <a href="../base-4.8.1.0/Data-Bool.html#t:Bool">Bool</a></li></ul>}</li><li class="src short"><span class="keyword">data</span> <a href="#t:SumEncoding">SumEncoding</a><ul class="subs"><li>= <a href="#v:TaggedObject">TaggedObject</a> { <ul class="subs"><li><a href="#v:tagFieldName">tagFieldName</a> :: <a href="../base-4.8.1.0/Data-String.html#t:String">String</a></li><li><a href="#v:contentsFieldName">contentsFieldName</a> :: <a href="../base-4.8.1.0/Data-String.html#t:String">String</a></li></ul> }</li><li>| <a href="#v:ObjectWithSingleField">ObjectWithSingleField</a></li><li>| <a href="#v:TwoElemArray">TwoElemArray</a></li></ul></li><li class="src short"><a href="#v:defaultOptions">defaultOptions</a> :: <a href="Data-Aeson-TH.html#t:Options">Options</a></li><li class="src short"><a href="#v:defaultTaggedObject">defaultTaggedObject</a> :: <a href="Data-Aeson-TH.html#t:SumEncoding">SumEncoding</a></li><li class="src short"><a href="#v:deriveJSON">deriveJSON</a> :: <a href="Data-Aeson-TH.html#t:Options">Options</a> -> <a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> -> <a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> [<a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Dec">Dec</a>]</li><li class="src short"><a href="#v:deriveToJSON">deriveToJSON</a> :: <a href="Data-Aeson-TH.html#t:Options">Options</a> -> <a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> -> <a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> [<a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Dec">Dec</a>]</li><li class="src short"><a href="#v:deriveFromJSON">deriveFromJSON</a> :: <a href="Data-Aeson-TH.html#t:Options">Options</a> -> <a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> -> <a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> [<a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Dec">Dec</a>]</li><li class="src short"><a href="#v:mkToJSON">mkToJSON</a> :: <a href="Data-Aeson-TH.html#t:Options">Options</a> -> <a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> -> <a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> <a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Exp">Exp</a></li><li class="src short"><a href="#v:mkToEncoding">mkToEncoding</a> :: <a href="Data-Aeson-TH.html#t:Options">Options</a> -> <a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> -> <a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> <a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Exp">Exp</a></li><li class="src short"><a href="#v:mkParseJSON">mkParseJSON</a> :: <a href="Data-Aeson-TH.html#t:Options">Options</a> -> <a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> -> <a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> <a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Exp">Exp</a></li></ul></div><div id="interface"><h1 id="g:1">Encoding configuration</h1><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:Options" class="def">Options</a> <a href="src/Data-Aeson-Types-Internal.html#Options" class="link">Source</a></p><div class="doc"><p>Options that specify how to encode/decode your datatype to/from JSON.</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:Options" class="def">Options</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div class="subs fields"><p class="caption">Fields</p><dl><dt class="src"><a name="v:fieldLabelModifier" class="def">fieldLabelModifier</a> :: <a href="../base-4.8.1.0/Data-String.html#t:String">String</a> -> <a href="../base-4.8.1.0/Data-String.html#t:String">String</a></dt><dd class="doc"><p>Function applied to field labels.
Handy for removing common record prefixes for example.</p></dd><dt class="src"><a name="v:constructorTagModifier" class="def">constructorTagModifier</a> :: <a href="../base-4.8.1.0/Data-String.html#t:String">String</a> -> <a href="../base-4.8.1.0/Data-String.html#t:String">String</a></dt><dd class="doc"><p>Function applied to constructor tags which could be handy
for lower-casing them for example.</p></dd><dt class="src"><a name="v:allNullaryToStringTag" class="def">allNullaryToStringTag</a> :: <a href="../base-4.8.1.0/Data-Bool.html#t:Bool">Bool</a></dt><dd class="doc"><p>If <code><a href="../base-4.8.1.0/Data-Bool.html#v:True">True</a></code> the constructors of a datatype, with <em>all</em>
nullary constructors, will be encoded to just a string with
the constructor tag. If <code><a href="../base-4.8.1.0/Data-Bool.html#v:False">False</a></code> the encoding will always
follow the <code><a href="Data-Aeson-TH.html#v:sumEncoding">sumEncoding</a></code>.</p></dd><dt class="src"><a name="v:omitNothingFields" class="def">omitNothingFields</a> :: <a href="../base-4.8.1.0/Data-Bool.html#t:Bool">Bool</a></dt><dd class="doc"><p>If <code><a href="../base-4.8.1.0/Data-Bool.html#v:True">True</a></code> record fields with a <code><a href="../base-4.8.1.0/Data-Maybe.html#v:Nothing">Nothing</a></code> value will be
omitted from the resulting object. If <code><a href="../base-4.8.1.0/Data-Bool.html#v:False">False</a></code> the resulting
object will include those fields mapping to <code>null</code>.</p></dd><dt class="src"><a name="v:sumEncoding" class="def">sumEncoding</a> :: <a href="Data-Aeson-TH.html#t:SumEncoding">SumEncoding</a></dt><dd class="doc"><p>Specifies how to encode constructors of a sum datatype.</p></dd><dt class="src"><a name="v:unwrapUnaryRecords" class="def">unwrapUnaryRecords</a> :: <a href="../base-4.8.1.0/Data-Bool.html#t:Bool">Bool</a></dt><dd class="doc"><p>Hide the field name when a record constructor has only one
field, like a newtype.</p></dd></dl><div class="clear"></div></div></td></tr></table></div><div class="subs instances"><p id="control.i:Options" class="caption collapser" onclick="toggleSection('i:Options')">Instances</p><div id="section.i:Options" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><a href="../base-4.8.1.0/Text-Show.html#t:Show">Show</a> <a href="Data-Aeson-TH.html#t:Options">Options</a></span> <a href="src/Data-Aeson-Types-Internal.html#line-480" class="link">Source</a></td><td class="doc empty"> </td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:SumEncoding" class="def">SumEncoding</a> <a href="src/Data-Aeson-Types-Internal.html#SumEncoding" class="link">Source</a></p><div class="doc"><p>Specifies how to encode constructors of a sum datatype.</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:TaggedObject" class="def">TaggedObject</a></td><td class="doc"><p>A constructor will be encoded to an object with a field
<code><a href="Data-Aeson-TH.html#v:tagFieldName">tagFieldName</a></code> which specifies the constructor tag (modified by
the <code><a href="Data-Aeson-TH.html#v:constructorTagModifier">constructorTagModifier</a></code>). If the constructor is a record
the encoded record fields will be unpacked into this object. So
make sure that your record doesn't have a field with the same
label as the <code><a href="Data-Aeson-TH.html#v:tagFieldName">tagFieldName</a></code>. Otherwise the tag gets overwritten
by the encoded value of that field! If the constructor is not a
record the encoded constructor contents will be stored under
the <code><a href="Data-Aeson-TH.html#v:contentsFieldName">contentsFieldName</a></code> field.</p></td></tr><tr><td colspan="2"><div class="subs fields"><p class="caption">Fields</p><dl><dt class="src"><a name="v:tagFieldName" class="def">tagFieldName</a> :: <a href="../base-4.8.1.0/Data-String.html#t:String">String</a></dt><dd class="doc empty"> </dd><dt class="src"><a name="v:contentsFieldName" class="def">contentsFieldName</a> :: <a href="../base-4.8.1.0/Data-String.html#t:String">String</a></dt><dd class="doc empty"> </dd></dl><div class="clear"></div></div></td></tr><tr><td class="src"><a name="v:ObjectWithSingleField" class="def">ObjectWithSingleField</a></td><td class="doc"><p>A constructor will be encoded to an object with a single
field named after the constructor tag (modified by the
<code><a href="Data-Aeson-TH.html#v:constructorTagModifier">constructorTagModifier</a></code>) which maps to the encoded contents of
the constructor.</p></td></tr><tr><td class="src"><a name="v:TwoElemArray" class="def">TwoElemArray</a></td><td class="doc"><p>A constructor will be encoded to a 2-element array where the
first element is the tag of the constructor (modified by the
<code><a href="Data-Aeson-TH.html#v:constructorTagModifier">constructorTagModifier</a></code>) and the second element the encoded
contents of the constructor.</p></td></tr></table></div><div class="subs instances"><p id="control.i:SumEncoding" class="caption collapser" onclick="toggleSection('i:SumEncoding')">Instances</p><div id="section.i:SumEncoding" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><a href="../base-4.8.1.0/Data-Eq.html#t:Eq">Eq</a> <a href="Data-Aeson-TH.html#t:SumEncoding">SumEncoding</a></span> <a href="src/Data-Aeson-Types-Internal.html#line-516" class="link">Source</a></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left"><a href="../base-4.8.1.0/Text-Show.html#t:Show">Show</a> <a href="Data-Aeson-TH.html#t:SumEncoding">SumEncoding</a></span> <a href="src/Data-Aeson-Types-Internal.html#line-516" class="link">Source</a></td><td class="doc empty"> </td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:defaultOptions" class="def">defaultOptions</a> :: <a href="Data-Aeson-TH.html#t:Options">Options</a> <a href="src/Data-Aeson-Types-Internal.html#defaultOptions" class="link">Source</a></p><div class="doc"><p>Default encoding <code><a href="Data-Aeson-TH.html#t:Options">Options</a></code>:</p><pre><code><a href="Data-Aeson-TH.html#t:Options">Options</a></code>
{ <code><a href="Data-Aeson-TH.html#v:fieldLabelModifier">fieldLabelModifier</a></code> = id
, <code><a href="Data-Aeson-TH.html#v:constructorTagModifier">constructorTagModifier</a></code> = id
, <code><a href="Data-Aeson-TH.html#v:allNullaryToStringTag">allNullaryToStringTag</a></code> = True
, <code><a href="Data-Aeson-TH.html#v:omitNothingFields">omitNothingFields</a></code> = False
, <code><a href="Data-Aeson-TH.html#v:sumEncoding">sumEncoding</a></code> = <code><a href="Data-Aeson-TH.html#v:defaultTaggedObject">defaultTaggedObject</a></code>
}
</pre></div></div><div class="top"><p class="src"><a name="v:defaultTaggedObject" class="def">defaultTaggedObject</a> :: <a href="Data-Aeson-TH.html#t:SumEncoding">SumEncoding</a> <a href="src/Data-Aeson-Types-Internal.html#defaultTaggedObject" class="link">Source</a></p><div class="doc"><p>Default <code><a href="Data-Aeson-TH.html#v:TaggedObject">TaggedObject</a></code> <code><a href="Data-Aeson-TH.html#t:SumEncoding">SumEncoding</a></code> options:</p><pre>defaultTaggedObject = <code><a href="Data-Aeson-TH.html#v:TaggedObject">TaggedObject</a></code>
{ <code><a href="Data-Aeson-TH.html#v:tagFieldName">tagFieldName</a></code> = "tag"
, <code><a href="Data-Aeson-TH.html#v:contentsFieldName">contentsFieldName</a></code> = "contents"
}
</pre></div></div><h1 id="g:2">FromJSON and ToJSON derivation</h1><div class="top"><p class="src"><a name="v:deriveJSON" class="def">deriveJSON</a> <a href="src/Data-Aeson-TH.html#deriveJSON" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Data-Aeson-TH.html#t:Options">Options</a></td><td class="doc"><p>Encoding options.</p></td></tr><tr><td class="src">-> <a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a></td><td class="doc"><p>Name of the type for which to generate <code><a href="Data-Aeson-Types.html#t:ToJSON">ToJSON</a></code> and <code><a href="Data-Aeson-Types.html#t:FromJSON">FromJSON</a></code>
instances.</p></td></tr><tr><td class="src">-> <a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> [<a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Dec">Dec</a>]</td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>Generates both <code><a href="Data-Aeson-Types.html#t:ToJSON">ToJSON</a></code> and <code><a href="Data-Aeson-Types.html#t:FromJSON">FromJSON</a></code> instance declarations for the given
data type or data family instance constructor.</p><p>This is a convienience function which is equivalent to calling both
<code><a href="Data-Aeson-TH.html#v:deriveToJSON">deriveToJSON</a></code> and <code><a href="Data-Aeson-TH.html#v:deriveFromJSON">deriveFromJSON</a></code>.</p></div></div><div class="top"><p class="src"><a name="v:deriveToJSON" class="def">deriveToJSON</a> <a href="src/Data-Aeson-TH.html#deriveToJSON" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Data-Aeson-TH.html#t:Options">Options</a></td><td class="doc"><p>Encoding options.</p></td></tr><tr><td class="src">-> <a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a></td><td class="doc"><p>Name of the type for which to generate a <code><a href="Data-Aeson-Types.html#t:ToJSON">ToJSON</a></code> instance
declaration.</p></td></tr><tr><td class="src">-> <a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> [<a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Dec">Dec</a>]</td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>Generates a <code><a href="Data-Aeson-Types.html#t:ToJSON">ToJSON</a></code> instance declaration for the given data type or
data family instance constructor.</p></div></div><div class="top"><p class="src"><a name="v:deriveFromJSON" class="def">deriveFromJSON</a> <a href="src/Data-Aeson-TH.html#deriveFromJSON" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Data-Aeson-TH.html#t:Options">Options</a></td><td class="doc"><p>Encoding options.</p></td></tr><tr><td class="src">-> <a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a></td><td class="doc"><p>Name of the type for which to generate a <code><a href="Data-Aeson-Types.html#t:FromJSON">FromJSON</a></code> instance
declaration.</p></td></tr><tr><td class="src">-> <a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> [<a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Dec">Dec</a>]</td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>Generates a <code><a href="Data-Aeson-Types.html#t:FromJSON">FromJSON</a></code> instance declaration for the given data type or
data family instance constructor.</p></div></div><div class="top"><p class="src"><a name="v:mkToJSON" class="def">mkToJSON</a> <a href="src/Data-Aeson-TH.html#mkToJSON" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Data-Aeson-TH.html#t:Options">Options</a></td><td class="doc"><p>Encoding options.</p></td></tr><tr><td class="src">-> <a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a></td><td class="doc"><p>Name of the type to encode.</p></td></tr><tr><td class="src">-> <a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> <a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Exp">Exp</a></td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>Generates a lambda expression which encodes the given data type or
data family instance constructor as a <code><a href="Data-Aeson-Types.html#t:Value">Value</a></code>.</p></div></div><div class="top"><p class="src"><a name="v:mkToEncoding" class="def">mkToEncoding</a> <a href="src/Data-Aeson-TH.html#mkToEncoding" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Data-Aeson-TH.html#t:Options">Options</a></td><td class="doc"><p>Encoding options.</p></td></tr><tr><td class="src">-> <a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a></td><td class="doc"><p>Name of the type to encode.</p></td></tr><tr><td class="src">-> <a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> <a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Exp">Exp</a></td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>Generates a lambda expression which encodes the given data type or
data family instance constructor as a JSON string.</p></div></div><div class="top"><p class="src"><a name="v:mkParseJSON" class="def">mkParseJSON</a> <a href="src/Data-Aeson-TH.html#mkParseJSON" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Data-Aeson-TH.html#t:Options">Options</a></td><td class="doc"><p>Encoding options.</p></td></tr><tr><td class="src">-> <a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a></td><td class="doc"><p>Name of the encoded type.</p></td></tr><tr><td class="src">-> <a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> <a href="../template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Exp">Exp</a></td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>Generates a lambda expression which parses the JSON encoding of the given
data type or data family instance constructor.</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.16.1</p></div></body></html>