on 1.3.1.1 help sign in
142 lines 2.9 kB history raw
1-- |
2-- Module: Data.Aeson.Types
3-- Copyright: (c) 2011-2016 Bryan O'Sullivan
4-- (c) 2011 MailRank, Inc.
5-- License: BSD3
6-- Maintainer: Bryan O'Sullivan <bos@serpentine.com>
7-- Stability: experimental
8-- Portability: portable
9--
10-- Types for working with JSON data.
12module Data.Aeson.Types
13 (
14 -- * Core JSON types
15 Value(..)
16 , Encoding
17 , unsafeToEncoding
18 , fromEncoding
19 , Series
20 , Array
21 , emptyArray
22 , Pair
23 , Object
24 , emptyObject
25 -- * Convenience types and functions
26 , DotNetTime(..)
27 , typeMismatch
28 -- * Type conversion
29 , Parser
30 , Result(..)
31 , FromJSON(..)
32 , fromJSON
33 , parse
34 , parseEither
35 , parseMaybe
36 , ToJSON(..)
37 , KeyValue(..)
38 , modifyFailure
39 , parserThrowError
40 , parserCatchError
42 -- ** Keys for maps
43 , ToJSONKey(..)
44 , ToJSONKeyFunction(..)
45 , toJSONKeyText
46 , contramapToJSONKeyFunction
47 , FromJSONKey(..)
48 , FromJSONKeyFunction(..)
49 , fromJSONKeyCoerce
50 , coerceFromJSONKeyFunction
51 , mapFromJSONKeyFunction
53 -- ** Liftings to unary and binary type constructors
54 , FromJSON1(..)
55 , parseJSON1
56 , FromJSON2(..)
57 , parseJSON2
58 , ToJSON1(..)
59 , toJSON1
60 , toEncoding1
61 , ToJSON2(..)
62 , toJSON2
63 , toEncoding2
65 -- ** Generic JSON classes
66 , GFromJSON(..)
67 , FromArgs(..)
68 , GToJSON
69 , GToEncoding
70 , ToArgs(..)
71 , Zero
72 , One
73 , genericToJSON
74 , genericLiftToJSON
75 , genericToEncoding
76 , genericLiftToEncoding
77 , genericParseJSON
78 , genericLiftParseJSON
80 -- * Inspecting @'Value's@
81 , withObject
82 , withText
83 , withArray
84 , withNumber
85 , withScientific
86 , withBool
87 , withEmbeddedJSON
89 , pairs
90 , foldable
91 , (.:)
92 , (.:?)
93 , (.:!)
94 , (.!=)
95 , object
96 , parseField
97 , parseFieldMaybe
98 , parseFieldMaybe'
99 , explicitParseField
100 , explicitParseFieldMaybe
101 , explicitParseFieldMaybe'
103 , listEncoding
104 , listValue
105 , listParser
107 -- * Generic and TH encoding configuration
108 , Options
110 -- ** Options fields
111 -- $optionsFields
112 , fieldLabelModifier
113 , constructorTagModifier
114 , allNullaryToStringTag
115 , omitNothingFields
116 , sumEncoding
117 , unwrapUnaryRecords
118 , tagSingleConstructors
120 -- ** Options utilities
121 , SumEncoding(..)
122 , camelTo
123 , camelTo2
124 , defaultOptions
125 , defaultTaggedObject
126 ) where
128import Prelude ()
129import Prelude.Compat
131import Data.Aeson.Encoding (Encoding, unsafeToEncoding, fromEncoding, Series, pairs)
132import Data.Aeson.Types.Class
133import Data.Aeson.Types.Internal
134import Data.Foldable (toList)
136-- | Encode a 'Foldable' as a JSON array.
137foldable :: (Foldable t, ToJSON a) => t a -> Encoding
138foldable = toEncoding . toList
139{-# INLINE foldable #-}
141-- $optionsFields
142-- The functions here are in fact record fields of the 'Options' type.