@@ -99,6 +99,7 @@ tests = testGroup "unit" [
9999 , testCase "Show Options" showOptions
100100 , testGroup "SingleMaybeField" singleMaybeField
101101 , testCase "withEmbeddedJSON" withEmbeddedJSONTest
102+ , testCase "SingleFieldCon" singleFieldCon
102103 ]
103104
104105roundTripCamel :: String -> Assertion
@@ -534,6 +535,17 @@ withEmbeddedJSONTest :: Assertion
534535withEmbeddedJSONTest =
535536 assertEqual "Unquote embedded JSON" (Right $ EmbeddedJSONTest 1) (eitherDecode "{\"prop\":\"1\"}")
536537
538+-- Regression test for https://github.com/bos/aeson/issues/627
539+newtype SingleFieldCon = SingleFieldCon Int deriving (Eq, Show, Generic)
540+
541+instance FromJSON SingleFieldCon where
542+ parseJSON = genericParseJSON defaultOptions{unwrapUnaryRecords=True}
543+ -- This option should have no effect on this type
544+
545+singleFieldCon :: Assertion
546+singleFieldCon =
547+ assertEqual "fromJSON" (Right (SingleFieldCon 0)) (eitherDecode "0")
548+
537549deriveJSON defaultOptions{omitNothingFields=True} ''MyRecord
538550
539551deriveToJSON defaultOptions ''Foo