Safe Haskell | None |
---|
- liftAeson :: (FromJSON a, ToJSON a) => Iso (Value :- t) (a :- t)
- option :: Iso (Value :- t) (a :- t) -> Iso (Value :- t) (Maybe a :- t)
- greedyOption :: Iso (Value :- t) (a :- t) -> Iso (Value :- t) (Maybe a :- t)
- list :: Iso (Value :- t) (a :- t) -> Iso (Value :- t) ([a] :- t)
- elementBy :: Iso (Value :- t1) t2 -> Iso ([Value] :- t1) ([Value] :- t2)
- array :: Iso ([Value] :- t1) ([Value] :- t2) -> Iso (Value :- t1) t2
- propBy :: Iso (Value :- t) (a :- t) -> String -> Iso (Object :- t) (Object :- (a :- t))
- rawFixedProp :: String -> Value -> Iso (Object :- t) (Object :- t)
- rest :: Iso (Object :- t) (Object :- (HashMap Text Value :- t))
- ignoreRest :: Iso (Object :- t) (Object :- t)
- object :: Iso (Object :- t1) (Object :- t2) -> Iso (Value :- t1) t2
- class Json a where
- fromJson :: Json a => Value -> Maybe a
- toJson :: Json a => a -> Maybe Value
- litJson :: Json a => a -> Iso (Value :- t) t
- prop :: Json a => String -> Iso (Object :- t) (Object :- (a :- t))
- fixedProp :: Json a => String -> a -> Iso (Object :- t) (Object :- t)
- element :: Json a => Iso ([Value] :- t) ([Value] :- (a :- t))
Constructing JSON grammars
liftAeson :: (FromJSON a, ToJSON a) => Iso (Value :- t) (a :- t)Source
Convert any Aeson-enabled type to a grammar.
list :: Iso (Value :- t) (a :- t) -> Iso (Value :- t) ([a] :- t)Source
Convert between a JSON array and Haskell list of arbitrary lengts. The elements are converted using the argument grammar.
elementBy :: Iso (Value :- t1) t2 -> Iso ([Value] :- t1) ([Value] :- t2)Source
Describe a single array element with the given grammar.
array :: Iso ([Value] :- t1) ([Value] :- t2) -> Iso (Value :- t1) t2Source
Wrap a bunch of elements in a JSON array. For example, to match an array of exactly length two:
array (element . element)
Or to match an empty array:
array id
propBy :: Iso (Value :- t) (a :- t) -> String -> Iso (Object :- t) (Object :- (a :- t))Source
Describe a property with the given name and value grammar.
rawFixedProp :: String -> Value -> Iso (Object :- t) (Object :- t)Source
Expect a specific key/value pair.
rest :: Iso (Object :- t) (Object :- (HashMap Text Value :- t))Source
Collect all properties left in an object.
ignoreRest :: Iso (Object :- t) (Object :- t)Source
Match and discard all properties left in the object. When converting back to JSON, produces no properties.
object :: Iso (Object :- t1) (Object :- t2) -> Iso (Value :- t1) t2Source
Wrap an exhaustive bunch of properties in an object. Typical usage:
object (prop "key1" . prop "key2")
Type-directed conversion
Convert values of a type to and from JSON.
Json Bool | |
Json Char | |
Json Double | |
Json Float | |
Json Int | |
Json Int8 | |
Json Int16 | |
Json Int32 | |
Json Int64 | |
Json Integer | |
Json Word | |
Json Word8 | |
Json Word16 | |
Json Word32 | |
Json Word64 | |
Json () | |
Json ByteString | |
Json Text | |
Json UTCTime | |
Json DotNetTime | |
Json Value | |
Json Number | |
Json Text | |
Json ByteString | |
Json IntSet | |
Json [Char] | |
Json a => Json [a] | |
Json a => Json (Maybe a) | |
(Json a, Json b) => Json (Either a b) |
prop :: Json a => String -> Iso (Object :- t) (Object :- (a :- t))Source
Describe a property whose value grammar is described by a Json
instance.