cabal-install-3.10.2.1: The command-line interface for Cabal and Hackage.

Safe Haskell | None
Language | Haskell2010

Distribution.Client.Utils.Json

Description

Minimal JSON / RFC 7159 support

The API is heavily inspired by `aeson`'s API but puts emphasis on simplicity rather than performance. The `ToJSON` instances are intended to have an encoding compatible with `aeson`'s encoding.

Synopsis

- data Value
  - = Object !Object
  - | Array [Value]
  - | String String
  - | Number !Double
  - | Bool !Bool
  - | Null
- type Object = [Pair]
- object :: [Pair] -> Value
- type Pair = (String, Value)
- (.=) :: ToJSON v => String -> v -> Pair
- encodeToString :: ToJSON a => a -> String
- encodeToBuilder :: ToJSON a => a -> Builder
- class ToJSON a where
  - toJSON :: a -> Value

# Documentation

data Value #

A JSON value represented as a Haskell value.

Constructors

Object !Object |
Array [Value] |
String String |
Number !Double |
Bool !Bool |
Null |

#### Instances

Instances details

IsString Value # |
Instance details Defined in Distribution.Client.Utils.Json Methods fromString :: String -> Value #
Read Value # |
Instance details Defined in Distribution.Client.Utils.Json Methods readsPrec :: Int -> ReadS Value # readList :: ReadS [Value] # readPrec :: ReadPrec Value # readListPrec :: ReadPrec [Value] #
Show Value # |
Instance details Defined in Distribution.Client.Utils.Json Methods showsPrec :: Int -> Value -> ShowS # show :: Value -> String # showList :: [Value] -> ShowS #
ToJSON Value # |
Instance details Defined in Distribution.Client.Utils.Json Methods toJSON :: Value -> Value #
Eq Value # |
Instance details Defined in Distribution.Client.Utils.Json Methods (==) :: Value -> Value -> Bool # (/=) :: Value -> Value -> Bool #

type Object = [Pair] #

A JSON "object" (key/value map).

object :: [Pair] -> Value #

Create a `Value` from a list of name/value `Pair`s.

type Pair = (String, Value) #

A key/value pair for an `Object`

(.=) :: ToJSON v => String -> v -> Pair infixr 8 #

A key-value pair for encoding a JSON object.

encodeToString :: ToJSON a => a -> String #

Serialise value as JSON-encoded Unicode `String`

encodeToBuilder :: ToJSON a => a -> Builder #

Serialise value as JSON/UTF8-encoded `Builder`

class ToJSON a where #

A type that can be converted to JSON.

Methods

toJSON :: a -> Value #

Convert a Haskell value to a JSON-friendly intermediate type.

#### Instances

Instances details

ToJSON Int16 # |
Instance details Defined in Distribution.Client.Utils.Json Methods toJSON :: Int16 -> Value #
ToJSON Int32 # |
Instance details Defined in Distribution.Client.Utils.Json Methods toJSON :: Int32 -> Value #
ToJSON Int64 # | Possibly lossy due to conversion to `Double`
Instance details Defined in Distribution.Client.Utils.Json Methods toJSON :: Int64 -> Value #
ToJSON Int8 # |
Instance details Defined in Distribution.Client.Utils.Json Methods toJSON :: Int8 -> Value #
ToJSON Word16 # |
Instance details Defined in Distribution.Client.Utils.Json Methods toJSON :: Word16 -> Value #
ToJSON Word32 # |
Instance details Defined in Distribution.Client.Utils.Json Methods toJSON :: Word32 -> Value #
ToJSON Word64 # | Possibly lossy due to conversion to `Double`
Instance details Defined in Distribution.Client.Utils.Json Methods toJSON :: Word64 -> Value #
ToJSON Word8 # |
Instance details Defined in Distribution.Client.Utils.Json Methods toJSON :: Word8 -> Value #
ToJSON Value # |
Instance details Defined in Distribution.Client.Utils.Json Methods toJSON :: Value -> Value #
ToJSON Integer # | Possibly lossy due to conversion to `Double`
Instance details Defined in Distribution.Client.Utils.Json Methods toJSON :: Integer -> Value #
ToJSON () # |
Instance details Defined in Distribution.Client.Utils.Json Methods toJSON :: () -> Value #
ToJSON Bool # |
Instance details Defined in Distribution.Client.Utils.Json Methods toJSON :: Bool -> Value #
ToJSON Double # |
Instance details Defined in Distribution.Client.Utils.Json Methods toJSON :: Double -> Value #
ToJSON Float # |
Instance details Defined in Distribution.Client.Utils.Json Methods toJSON :: Float -> Value #
ToJSON Int # |
Instance details Defined in Distribution.Client.Utils.Json Methods toJSON :: Int -> Value #
ToJSON Word # |
Instance details Defined in Distribution.Client.Utils.Json Methods toJSON :: Word -> Value #
ToJSON a => ToJSON (Maybe a) # |
Instance details Defined in Distribution.Client.Utils.Json Methods toJSON :: Maybe a -> Value #
ToJSON a => ToJSON [a] # |
Instance details Defined in Distribution.Client.Utils.Json Methods toJSON :: [a] -> Value #
(ToJSON a, ToJSON b) => ToJSON (a, b) # |
Instance details Defined in Distribution.Client.Utils.Json Methods toJSON :: (a, b) -> Value #
(ToJSON a, ToJSON b, ToJSON c) => ToJSON (a, b, c) # |
Instance details Defined in Distribution.Client.Utils.Json Methods toJSON :: (a, b, c) -> Value #
(ToJSON a, ToJSON b, ToJSON c, ToJSON d) => ToJSON (a, b, c, d) # |
Instance details Defined in Distribution.Client.Utils.Json Methods toJSON :: (a, b, c, d) -> Value #