on 47fe2cd help sign in
43 lines 1.0 kB history raw
1{-# LANGUAGE DeriveDataTypeable #-}
2{-# LANGUAGE GeneralizedNewtypeDeriving #-}
3{-# LANGUAGE ScopedTypeVariables #-}
5-- |
6-- Module : Network.Google.Data.JSON
7-- Copyright : (c) 2015 Brendan Hay <brendan.g.hay@gmail.com>
8-- License : Mozilla Public License, v. 2.0.
9-- Maintainer : Brendan Hay <brendan.g.hay@gmail.com>
10-- Stability : provisional
11-- Portability : non-portable (GHC extensions)
12--
13module Network.Google.Data.JSON
14 ( module Network.Google.Data.JSON
16 , FromJSON (..)
17 , ToJSON (..)
19 , withObject
20 , emptyObject
21 , object
23 , (.=)
24 , (.:)
25 , (.:?)
26 , (.!=)
27 ) where
29import Control.Lens hiding ((.=))
30import Data.Aeson
31import Data.Aeson.Types
32import Servant.API
34type JSONValue = Value
36emptyObject :: Value
37emptyObject = Object mempty
39parseJSONText :: FromText a => String -> Value -> Parser a
40parseJSONText n = withText n (maybe (fail n) pure . fromText)
42toJSONText :: ToText a => a -> Value
43toJSONText = String . toText