Module

# Yoga.JSON

- Package
- purescript-yoga-json
- Repository
- rowtype-yoga/purescript-yoga-json

### #E Source

`type E a = Either MultipleErrors a`

An alias for the Either result of decoding

### #readJSON Source

`readJSON :: forall a. ReadForeign a => String -> E a`

Read a JSON string to a type `a`

while returning a `MultipleErrors`

if the
parsing failed.

### #readJSON' Source

`readJSON' :: forall a. ReadForeign a => String -> F a`

Read a JSON string to a type `a`

using `F a`

. Useful with record types.

### #readJSON_ Source

`readJSON_ :: forall a. ReadForeign a => String -> Maybe a`

Read a JSON string to a type `a`

while returning `Nothing`

if the parsing
failed.

### #writeJSON Source

`writeJSON :: forall a. WriteForeign a => a -> String`

Write a JSON string from a type `a`

.

### #writePrettyJSON Source

`writePrettyJSON :: forall a. WriteForeign a => Int -> a -> String`

### #write Source

`write :: forall a. WriteForeign a => a -> Foreign`

### #read_ Source

`read_ :: forall a. ReadForeign a => Foreign -> Maybe a`

Read a Foreign value to a type, as a Maybe of type

### #unsafeStringify Source

`unsafeStringify :: forall a. a -> String`

### #ReadForeign Source

`class ReadForeign a where`

A class for reading foreign values to a type

#### Members

#### Instances

`ReadForeign Foreign`

`ReadForeign Char`

`ReadForeign Number`

`ReadForeign Int`

`ReadForeign BigInt`

`ReadForeign String`

`ReadForeign NonEmptyString`

`ReadForeign Boolean`

`(ReadForeign a) => ReadForeign (Array a)`

`(ReadForeign a) => ReadForeign (Maybe a)`

`(ReadForeign a) => ReadForeign (Nullable a)`

`(ReadForeign a, ReadForeign b) => ReadForeign (Either a b)`

`(ReadForeign a) => ReadForeign (Object a)`

`(ReadTuple (Tuple a b)) => ReadForeign (Tuple a b)`

`(RowToList fields fieldList, ReadForeignFields fieldList () fields) => ReadForeign (Record fields)`

`(RowToList variants rl, ReadForeignVariant rl variants) => ReadForeign (Variant variants)`

`(ReadForeign a) => ReadForeign (NonEmptyArray a)`

`(ReadForeign a) => ReadForeign (Map String a)`

`(ReadForeign a) => ReadForeign (Map Int a)`

`(ReadForeign a) => ReadForeign (Map BigInt a)`

`(Newtype nt key, ReadForeign (Map key value)) => ReadForeign (Map nt value)`

`ReadForeign JSDate`

`ReadForeign DateTime`

`ReadForeign Instant`

`ReadForeign Milliseconds`

`ReadForeign Seconds`

`ReadForeign Minutes`

`ReadForeign Hours`

`ReadForeign Days`

`(ReadForeign a) => ReadForeign (Tree a)`

### #ReadForeignFields Source

`class ReadForeignFields :: RowList Type -> Row Type -> Row Type -> Constraint`

`class ReadForeignFields (xs :: RowList Type) (from :: Row Type) (to :: Row Type) | xs -> from to where`

A class for reading foreign values from properties

#### Members

#### Instances

`(IsSymbol name, ReadForeign ty, ReadForeignFields tail from from', Lacks name from', Cons name ty from' to) => ReadForeignFields (Cons name ty tail) from to`

`ReadForeignFields Nil () ()`

### #ReadForeignVariant Source

`class ReadForeignVariant :: RowList Type -> Row Type -> Constraint`

`class ReadForeignVariant (xs :: RowList Type) (row :: Row Type) | xs -> row where`

#### Members

`readVariantImpl :: Proxy xs -> Foreign -> F (Variant row)`

#### Instances

`(IsSymbol name, ReadForeign ty, Cons name ty trash row, ReadForeignVariant tail row) => ReadForeignVariant (Cons name ty tail) row`

`ReadForeignVariant Nil trash`

### #ReadTuple Source

`class ReadTuple a where`

A class for reading JSON arrays of lenth `n`

as nested tuples of size `n`

#### Members

#### Instances

`(ReadForeign a, ReadTuple (Tuple b c)) => ReadTuple (Tuple a (Tuple b c))`

`(ReadForeign a, ReadForeign b) => ReadTuple (Tuple a b)`

### #WriteForeign Source

`class WriteForeign a where`

#### Members

#### Instances

`WriteForeign Foreign`

`WriteForeign String`

`WriteForeign NonEmptyString`

`WriteForeign Int`

`WriteForeign Char`

`WriteForeign Number`

`WriteForeign BigInt`

`WriteForeign Boolean`

`(WriteForeign a) => WriteForeign (Array a)`

`(WriteForeign a) => WriteForeign (Maybe a)`

`(WriteForeign a) => WriteForeign (Nullable a)`

`(WriteForeign a, WriteForeign b) => WriteForeign (Either a b)`

`(WriteForeign a) => WriteForeign (Object a)`

`(WriteForeign a, WriteForeign (Tuple b c)) => WriteForeign (Tuple a (Tuple b c))`

`(WriteForeign a, WriteForeign b) => WriteForeign (Tuple a b)`

`(RowToList row rl, WriteForeignFields rl row () to) => WriteForeign (Record row)`

`(RowToList row rl, WriteForeignVariant rl row) => WriteForeign (Variant row)`

`(WriteForeign a) => WriteForeign (NonEmptyArray a)`

`(WriteForeign a) => WriteForeign (Map String a)`

`(WriteForeign a) => WriteForeign (Map Int a)`

`(WriteForeign a) => WriteForeign (Map BigInt a)`

`(Newtype nt key, WriteForeign (Map key value)) => WriteForeign (Map nt value)`

`WriteForeign JSDate`

`WriteForeign DateTime`

`WriteForeign Instant`

`WriteForeign Milliseconds`

`WriteForeign Seconds`

`WriteForeign Minutes`

`WriteForeign Hours`

`WriteForeign Days`

`(WriteForeign a) => WriteForeign (Tree a)`

### #WriteForeignFields Source

`class WriteForeignFields :: RowList Type -> Row Type -> Row Type -> Row Type -> Constraint`

`class WriteForeignFields (rl :: RowList Type) row (from :: Row Type) (to :: Row Type) | rl -> row from to where`

#### Members

`writeImplFields :: forall g. g rl -> Record row -> Builder (Record from) (Record to)`

#### Instances

`(IsSymbol name, WriteForeign ty, WriteForeignFields tail row from from', Cons name ty whatever row, Lacks name from', Cons name Foreign from' to) => WriteForeignFields (Cons name ty tail) row from to`

`WriteForeignFields Nil row () ()`

### #WriteForeignVariant Source

`class WriteForeignVariant :: RowList Type -> Row Type -> Constraint`

`class WriteForeignVariant (rl :: RowList Type) (row :: Row Type) | rl -> row where`

#### Members

`writeVariantImpl :: forall g. g rl -> Variant row -> Foreign`

#### Instances

`WriteForeignVariant Nil ()`

`(IsSymbol name, WriteForeign ty, Cons name ty subRow row, WriteForeignVariant tail subRow) => WriteForeignVariant (Cons name ty tail) row`