diff --git a/src/Data/JSON/Fields.hs b/src/Data/JSON/Fields.hs index 07b5bfde9..a3d93d8c3 100644 --- a/src/Data/JSON/Fields.hs +++ b/src/Data/JSON/Fields.hs @@ -35,3 +35,10 @@ newtype JSONFields a = JSONFields { unJSONFields :: a } instance (ToJSONFields a) => ToJSON (JSONFields a) where toJSON = object . toJSONFields . unJSONFields toEncoding = pairs . mconcat . toJSONFields . unJSONFields + + +newtype JSONFields1 f a = JSONFields1 { unJSONFields1 :: f a } + +instance (ToJSON a, ToJSONFields1 f) => ToJSON (JSONFields1 f a) where + toJSON = object . toJSONFields1 . unJSONFields1 + toEncoding = pairs . mconcat . toJSONFields1 . unJSONFields1