on 9ea0bb9 help sign in
42 lines 986 B 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 ( JSONValue
15 , parseJSONText
16 , toJSONText
18 -- * Re-exports
19 , FromJSON (..)
20 , ToJSON (..)
22 , withObject
23 , emptyObject
24 , object
26 , (.=)
27 , (.:)
28 , (.:?)
29 , (.!=)
30 ) where
32import Data.Aeson
33import Data.Aeson.Types
34import Servant.API
36type JSONValue = Value
38parseJSONText :: FromText a => String -> Value -> Parser a
39parseJSONText n = withText n (maybe (fail n) pure . fromText)
41toJSONText :: ToText a => a -> Value
42toJSONText = String . toText