Module

Aeson

Uses json-bigint library to parse JSON. Stores integers as BigInts and numbers with decimals as Number API and behaviour is intended to be close to Aeson.

#(.:)

Operator alias for Aeson.getField (non-associative / precedence 7)

#(.:?)

Operator alias for Aeson.getFieldOptional' (non-associative / precedence 7)

#(.:!)

Operator alias for Aeson.getFieldOptional (non-associative / precedence 7)

#Aeson

data Aeson

A piece of JSON where all numbers are represented as BigInt

Instances

#AesonCases

type AesonCases a = { caseArray :: Array Aeson -> a, caseBigInt :: BigInt -> a, caseBoolean :: Boolean -> a, caseFiniteNumber :: Finite Number -> a, caseNull :: Unit -> a, caseObject :: Object Aeson -> a, caseString :: String -> a }

Utility abbrevation. See caseAeson for an example usage.

#Finite

newtype Finite a

Finite Number is just like Number but can not be an Infinity or NaN. Underlying JSON parser ensures parsed numbers are not NaN or Infinity. You can construct Finite Number using finiteNumber smart constructor.

Instances

#unFinite

unFinite :: forall a. Finite a -> a

#GEncodeAeson

class GEncodeAeson :: Row Type -> RowList Type -> Constraintclass GEncodeAeson (row :: Row Type) (list :: RowList Type)  where

Members

Instances

#GDecodeAeson

class GDecodeAeson :: Row Type -> RowList Type -> Constraintclass GDecodeAeson (row :: Row Type) (list :: RowList Type) | list -> row where

Members

Instances

#caseAeson

caseAeson :: forall a. AesonCases a -> Aeson -> a

#caseAesonArray

caseAesonArray :: forall (a :: Type). a -> (Array Aeson -> a) -> Aeson -> a

#caseAesonBoolean

caseAesonBoolean :: forall (a :: Type). a -> (Boolean -> a) -> Aeson -> a

#caseAesonBigInt

caseAesonBigInt :: forall (a :: Type). a -> (BigInt -> a) -> Aeson -> a

caseAesonBigInt specialized to BigInt (fails if no parse)

#caseAesonFiniteNumber

caseAesonFiniteNumber :: forall (a :: Type). a -> (Finite Number -> a) -> Aeson -> a

caseAesonFiniteNumber specialized to Finite Number (fails if no parse)

#caseAesonInt

caseAesonInt :: forall (a :: Type). a -> (Int -> a) -> Aeson -> a

caseAesonBigInt specialized to Int (fails if no parse)

#caseAesonNull

caseAesonNull :: forall (a :: Type). a -> (Unit -> a) -> Aeson -> a

#caseAesonNumber

caseAesonNumber :: forall (a :: Type). a -> (Number -> a) -> Aeson -> a

caseAesonNumber specialized to Number (fails if no parse)

#caseAesonObject

caseAesonObject :: forall (a :: Type). a -> (Object Aeson -> a) -> Aeson -> a

#caseAesonString

caseAesonString :: forall (a :: Type). a -> (String -> a) -> Aeson -> a

#caseAesonUInt

caseAesonUInt :: forall (a :: Type). a -> (UInt -> a) -> Aeson -> a

caseAesonBigInt specialized to UInt (fails if no parse)

#constAesonCases

constAesonCases :: forall (a :: Type). a -> AesonCases a

#decodeJsonString

decodeJsonString :: forall (a :: Type). DecodeAeson a => String -> Either JsonDecodeError a

Decodes a value encoded as JSON via Aeson decoding algorithm.

#getField

#getFieldOptional

getFieldOptional :: forall (a :: Type). DecodeAeson a => Object Aeson -> String -> Either JsonDecodeError (Maybe a)

Attempt to get the value for a given key on an Object Aeson.

The result will be Right Nothing if the key and value are not present, but will fail if the key is present but the value cannot be converted to the right type.

This function will treat null as a value and attempt to decode it into your desired type. If you would like to treat null values the same as absent values, use getFieldOptional' (.:?) instead.

#getFieldOptional'

getFieldOptional' :: forall (a :: Type). DecodeAeson a => Object Aeson -> String -> Either JsonDecodeError (Maybe a)

Attempt to get the value for a given key on an Object Aeson.

The result will be Right Nothing if the key and value are not present, or if the key is present and the value is null.

Use this accessor if the key and value are optional in your object. If the key and value are mandatory, use getField (.:) instead.

#getNestedAeson

getNestedAeson :: Aeson -> Array String -> Either JsonDecodeError Aeson

Returns an Aeson available under a sequence of keys in given Aeson. If not possible returns JsonDecodeError.

#jsonToAeson

jsonToAeson :: Json -> Aeson

Recodes Argonaut Json to Aeson.

#stringifyAeson

#isArray

isArray :: Aeson -> Boolean

Check if the provided Aeson is an Array

#isBigInt

isBigInt :: Aeson -> Boolean

Check if the provided Aeson is a BigInt

#isBoolean

isBoolean :: Aeson -> Boolean

Check if the provided Aeson is a Boolean

#isInt

isInt :: Aeson -> Boolean

Check if the provided Aeson is a Int

#isNull

isNull :: Aeson -> Boolean

Check if the provided Json is the null value

#isNumber

isNumber :: Aeson -> Boolean

Check if the provided Aeson is a Number

#isObject

isObject :: Aeson -> Boolean

Check if the provided Aeson is an Object

#isString

isString :: Aeson -> Boolean

Check if the provided Aeson is a String

#isUInt

isUInt :: Aeson -> Boolean

Check if the provided Aeson is a UInt

#toArray

toArray :: Aeson -> Maybe (Array Aeson)

Convert Aeson to an Array of Aeson values, if the Aeson is an array.

#toBigInt

toBigInt :: Aeson -> Maybe BigInt

Convert Aeson to a BigInt value, if the Aeson can be treated as BigInt.

#toBoolean

toBoolean :: Aeson -> Maybe Boolean

Convert Aeson to a Boolean value, if the Aeson is a boolean.

#toInt

toInt :: Aeson -> Maybe Int

Convert Aeson to a Int value, if the Aeson can be treated as Int.

#toNull

toNull :: Aeson -> Maybe Unit

Convert Aeson to the Unit value if the Aeson is the null value

#toNumber

toNumber :: Aeson -> Maybe Number

Convert Aeson to a Number value, if the Aeson can be treated as Number.

#toObject

toObject :: Aeson -> Maybe (Object Aeson)

Convert Aeson to an Object of Aeson values, if the Aeson is an object.

#toString

toString :: Aeson -> Maybe String

Convert Aeson to a String value, if the Aeson is a string. To write a Aeson value to a JSON string, see stringify.

#toUInt

toUInt :: Aeson -> Maybe UInt

Convert Aeson to a UInt value, if the Aeson can be treated as UInt.

#finiteNumber

finiteNumber :: Number -> Maybe (Finite Number)

Returns Nothing if input is Infinity or NaN

#aesonNull

#fromArray

#fromBigInt

#fromBoolean

fromBoolean :: Boolean -> Aeson

Construct the Json representation of a * value. Note that this function only produces Json containing a single piece of *

#fromInt

#fromFiniteNumber

#fromObject

#fromString

fromString :: String -> Aeson

This function does NOT convert the String encoding of a JSON value to Json

#fromUInt

#toStringifiedNumbersJson

toStringifiedNumbersJson :: Aeson -> Json

Replaces numbers the Aeson's payload with stringified numbers Given original payload of: {"a": 10} The result will be an Json object representing: {"a": "10"}

#EncodeTupleAux

class EncodeTupleAux a  where

Members

Instances

#DecodeTupleAux

Re-exports from Data.Argonaut

#printJsonDecodeError

printJsonDecodeError :: JsonDecodeError -> String

Prints a JsonDecodeError as a readable error message.

Modules