planet-mitchell-0.1.0: Planet Mitchell

Safe HaskellNone
LanguageHaskell2010

Json

Contents

Description

JSON functionality common to both encoding and decoding. Re-exported by both Json.Encode and Json.Decode for convenience.

Synopsis

Documentation

data Value #

A JSON value represented as a Haskell value.

Instances
Eq Value 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

(==) :: Value -> Value -> Bool #

(/=) :: Value -> Value -> Bool #

Data Value 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Value -> c Value #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Value #

toConstr :: Value -> Constr #

dataTypeOf :: Value -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Value) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Value) #

gmapT :: (forall b. Data b => b -> b) -> Value -> Value #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Value -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Value -> r #

gmapQ :: (forall d. Data d => d -> u) -> Value -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Value -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Value -> m Value #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Value -> m Value #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Value -> m Value #

Read Value 
Instance details

Defined in Data.Aeson.Types.Internal

Show Value 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

showsPrec :: Int -> Value -> ShowS #

show :: Value -> String #

showList :: [Value] -> ShowS #

IsString Value 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

fromString :: String -> Value #

Generic Value 
Instance details

Defined in Data.Aeson.Types.Internal

Associated Types

type Rep Value :: * -> * #

Methods

from :: Value -> Rep Value x #

to :: Rep Value x -> Value #

Lift Value 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

lift :: Value -> Q Exp #

Hashable Value 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

hashWithSalt :: Int -> Value -> Int #

hash :: Value -> Int #

ToJSON Value 
Instance details

Defined in Data.Aeson.Types.ToJSON

KeyValue Pair 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

(.=) :: ToJSON v => Text -> v -> Pair #

FromJSON Value 
Instance details

Defined in Data.Aeson.Types.FromJSON

NFData Value 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

rnf :: Value -> () #

AsNumber Value 
Instance details

Defined in Data.Aeson.Lens

AsPrimitive Value 
Instance details

Defined in Data.Aeson.Lens

AsValue Value 
Instance details

Defined in Data.Aeson.Lens

AsJSON Value 
Instance details

Defined in Data.Aeson.Lens

Methods

_JSON :: (FromJSON a, ToJSON a) => Prism' Value a #

FromString Encoding 
Instance details

Defined in Data.Aeson.Types.ToJSON

FromString Value 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

fromString :: String -> Value

GToJSON Encoding arity (U1 :: * -> *) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Encoding arity a -> U1 a -> Encoding

GToJSON Value arity (V1 :: * -> *) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Value arity a -> V1 a -> Value

GToJSON Value arity (U1 :: * -> *) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Value arity a -> U1 a -> Value

ToJSON1 f => GToJSON Encoding One (Rec1 f) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Encoding One a -> Rec1 f a -> Encoding

ToJSON1 f => GToJSON Value One (Rec1 f) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Value One a -> Rec1 f a -> Value

ToJSON a => GToJSON Encoding arity (K1 i a :: * -> *) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Encoding arity a0 -> K1 i a a0 -> Encoding

(EncodeProduct arity a, EncodeProduct arity b) => GToJSON Encoding arity (a :*: b) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Encoding arity a0 -> (a :*: b) a0 -> Encoding

ToJSON a => GToJSON Value arity (K1 i a :: * -> *) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Value arity a0 -> K1 i a a0 -> Value

(WriteProduct arity a, WriteProduct arity b, ProductSize a, ProductSize b) => GToJSON Value arity (a :*: b) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Value arity a0 -> (a :*: b) a0 -> Value

(ToJSON1 f, GToJSON Encoding One g) => GToJSON Encoding One (f :.: g) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Encoding One a -> (f :.: g) a -> Encoding

(ToJSON1 f, GToJSON Value One g) => GToJSON Value One (f :.: g) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Value One a -> (f :.: g) a -> Value

FromPairs Value (DList Pair) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

fromPairs :: DList Pair -> Value

v ~ Value => KeyValuePair v (DList Pair) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

pair :: String -> v -> DList Pair

(GToJSON Encoding arity a, ConsToJSON Encoding arity a, Constructor c) => SumToJSON' TwoElemArray Encoding arity (C1 c a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

sumToJSON' :: Options -> ToArgs Encoding arity a0 -> C1 c a a0 -> Tagged TwoElemArray Encoding

(GToJSON Value arity a, ConsToJSON Value arity a, Constructor c) => SumToJSON' TwoElemArray Value arity (C1 c a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

sumToJSON' :: Options -> ToArgs Value arity a0 -> C1 c a a0 -> Tagged TwoElemArray Value

type Rep Value 
Instance details

Defined in Data.Aeson.Types.Internal

type Index Value 
Instance details

Defined in Data.Aeson.Lens

type IxValue Value 
Instance details

Defined in Data.Aeson.Lens

data Primitive #

Primitives of Value

Instances
Eq Primitive 
Instance details

Defined in Data.Aeson.Lens

Data Primitive 
Instance details

Defined in Data.Aeson.Lens

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Primitive -> c Primitive #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Primitive #

toConstr :: Primitive -> Constr #

dataTypeOf :: Primitive -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Primitive) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Primitive) #

gmapT :: (forall b. Data b => b -> b) -> Primitive -> Primitive #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Primitive -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Primitive -> r #

gmapQ :: (forall d. Data d => d -> u) -> Primitive -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Primitive -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Primitive -> m Primitive #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Primitive -> m Primitive #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Primitive -> m Primitive #

Ord Primitive 
Instance details

Defined in Data.Aeson.Lens

Show Primitive 
Instance details

Defined in Data.Aeson.Lens

AsNumber Primitive 
Instance details

Defined in Data.Aeson.Lens

AsPrimitive Primitive 
Instance details

Defined in Data.Aeson.Lens

Prisms

_Number :: AsNumber t => Prism' t Scientific #

>>> "[1, \"x\"]" ^? nth 0 . _Number
Just 1.0
>>> "[1, \"x\"]" ^? nth 1 . _Number
Nothing

_Double :: AsNumber t => Prism' t Double #

Prism into an Double over a Value, Primitive or Scientific

>>> "[10.2]" ^? nth 0 . _Double
Just 10.2

_Integer :: AsNumber t => Prism' t Integer #

Prism into an Integer over a Value, Primitive or Scientific

>>> "[10]" ^? nth 0 . _Integer
Just 10
>>> "[10.5]" ^? nth 0 . _Integer
Just 10
>>> "42" ^? _Integer
Just 42

_Integral :: (AsNumber t, Integral a) => Prism' t a #

Access Integer Values as Integrals.

>>> "[10]" ^? nth 0 . _Integral
Just 10
>>> "[10.5]" ^? nth 0 . _Integral
Just 10

nonNull :: Prism' Value Value #

Prism into non-Null values

>>> "{\"a\": \"xyz\", \"b\": null}" ^? key "a" . nonNull
Just (String "xyz")
>>> "{\"a\": {}, \"b\": null}" ^? key "a" . nonNull
Just (Object (fromList []))
>>> "{\"a\": \"xyz\", \"b\": null}" ^? key "b" . nonNull
Nothing

_Primitive :: AsPrimitive t => Prism' t Primitive #

>>> "[1, \"x\", null, true, false]" ^? nth 0 . _Primitive
Just (NumberPrim 1.0)
>>> "[1, \"x\", null, true, false]" ^? nth 1 . _Primitive
Just (StringPrim "x")
>>> "[1, \"x\", null, true, false]" ^? nth 2 . _Primitive
Just NullPrim
>>> "[1, \"x\", null, true, false]" ^? nth 3 . _Primitive
Just (BoolPrim True)
>>> "[1, \"x\", null, true, false]" ^? nth 4 . _Primitive
Just (BoolPrim False)

_String :: AsPrimitive t => Prism' t Text #

>>> "{\"a\": \"xyz\", \"b\": true}" ^? key "a" . _String
Just "xyz"
>>> "{\"a\": \"xyz\", \"b\": true}" ^? key "b" . _String
Nothing
>>> _Object._Wrapped # [("key" :: Text, _String # "value")] :: String
"{\"key\":\"value\"}"

_Bool :: AsPrimitive t => Prism' t Bool #

>>> "{\"a\": \"xyz\", \"b\": true}" ^? key "b" . _Bool
Just True
>>> "{\"a\": \"xyz\", \"b\": true}" ^? key "a" . _Bool
Nothing
>>> _Bool # True :: String
"true"
>>> _Bool # False :: String
"false"

_Null :: AsPrimitive t => Prism' t () #

>>> "{\"a\": \"xyz\", \"b\": null}" ^? key "b" . _Null
Just ()
>>> "{\"a\": \"xyz\", \"b\": null}" ^? key "a" . _Null
Nothing
>>> _Null # () :: String
"null"

_Value :: AsValue t => Prism' t Value #

>>> preview _Value "[1,2,3]" == Just (Array (Vector.fromList [Number 1.0,Number 2.0,Number 3.0]))
True

_Object :: AsValue t => Prism' t (HashMap Text Value) #

>>> "{\"a\": {}, \"b\": null}" ^? key "a" . _Object
Just (fromList [])
>>> "{\"a\": {}, \"b\": null}" ^? key "b" . _Object
Nothing
>>> _Object._Wrapped # [("key" :: Text, _String # "value")] :: String
"{\"key\":\"value\"}"

_Array :: AsValue t => Prism' t (Vector Value) #

>>> preview _Array "[1,2,3]" == Just (Vector.fromList [Number 1.0,Number 2.0,Number 3.0])
True

class AsJSON t #

Minimal complete definition

_JSON

Instances
AsJSON String 
Instance details

Defined in Data.Aeson.Lens

Methods

_JSON :: (FromJSON a, ToJSON a) => Prism' String a #

AsJSON ByteString 
Instance details

Defined in Data.Aeson.Lens

Methods

_JSON :: (FromJSON a, ToJSON a) => Prism' ByteString a #

AsJSON ByteString 
Instance details

Defined in Data.Aeson.Lens

Methods

_JSON :: (FromJSON a, ToJSON a) => Prism' ByteString a #

AsJSON Text 
Instance details

Defined in Data.Aeson.Lens

Methods

_JSON :: (FromJSON a, ToJSON a) => Prism' Text a #

AsJSON Value 
Instance details

Defined in Data.Aeson.Lens

Methods

_JSON :: (FromJSON a, ToJSON a) => Prism' Value a #

AsJSON Text 
Instance details

Defined in Data.Aeson.Lens

Methods

_JSON :: (FromJSON a, ToJSON a) => Prism' Text a #

_JSON :: (AsJSON t, FromJSON a, ToJSON a) => Prism' t a #

_JSON is a Prism from something containing JSON to something encoded in that structure

Traversals

key :: AsValue t => Text -> Traversal' t Value #

Like ix, but for Object with Text indices. This often has better inference than ix when used with OverloadedStrings.

>>> "{\"a\": 100, \"b\": 200}" ^? key "a"
Just (Number 100.0)
>>> "[1,2,3]" ^? key "a"
Nothing

members :: AsValue t => IndexedTraversal' Text t Value #

An indexed Traversal into Object properties

>>> "{\"a\": 4, \"b\": 7}" ^@.. members
[("a",Number 4.0),("b",Number 7.0)]
>>> "{\"a\": 4, \"b\": 7}" & members . _Number *~ 10
"{\"a\":40,\"b\":70}"

nth :: AsValue t => Int -> Traversal' t Value #

Like ix, but for Arrays with Int indexes

>>> "[1,2,3]" ^? nth 1
Just (Number 2.0)
>>> "\"a\": 100, \"b\": 200}" ^? nth 1
Nothing
>>> "[1,2,3]" & nth 1 .~ Number 20
"[1,20,3]"

values :: AsValue t => IndexedTraversal' Int t Value #

An indexed Traversal into Array elements

>>> "[1,2,3]" ^.. values
[Number 1.0,Number 2.0,Number 3.0]
>>> "[1,2,3]" & values . _Number *~ 10
"[10,20,30]"