Skip to content

Commit e98b90e

Browse files
committed
Add To/FromJSONKey Void instances
1 parent b0fa0f6 commit e98b90e

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ For the latest version of this document, please see [https://github.com/haskell/
44

55
* Support deriving for empty datatypes (such as `Void` and `V1`)
66
in `FromJSON` and `ToJSON`.
7+
* Add `To/FromJSONKey Void` instances
78

89
### 2.1.1.0
910

src/Data/Aeson/Types/FromJSON.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,6 +1542,10 @@ instance (FromJSON a, FromJSON b) => FromJSON (Either a b) where
15421542
instance FromJSON Void where
15431543
parseJSON _ = fail "Cannot parse Void"
15441544

1545+
-- | @since 2.1.2.0
1546+
instance FromJSONKey Void where
1547+
fromJSONKey = FromJSONKeyTextParser $ \_ -> fail "Cannot parse Void"
1548+
15451549
instance FromJSON Bool where
15461550
parseJSON (Bool b) = pure b
15471551
parseJSON v = typeMismatch "Bool" v

src/Data/Aeson/Types/ToJSON.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,6 +1313,10 @@ instance ToJSON Void where
13131313
toJSON = absurd
13141314
toEncoding = absurd
13151315

1316+
-- | @since 2.1.2.0
1317+
instance ToJSONKey Void where
1318+
toJSONKey = ToJSONKeyText absurd absurd
1319+
13161320
instance ToJSON Bool where
13171321
toJSON = Bool
13181322
toEncoding = E.bool

0 commit comments

Comments
 (0)