@@ -27,7 +27,7 @@ import Data.Aeson ((.=), (.:), (.:?), (.:!), FromJSON(..), FromJSONKeyFunction(.
2727import Data.Aeson.Internal (JSONPathElement(..), formatError)
2828import Data.Aeson.TH (deriveJSON, deriveToJSON, deriveToJSON1)
2929import Data.Aeson.Text (encodeToTextBuilder)
30−import Data.Aeson.Types (Options(..), Result(Success), ToJSON(..), Value(Null), camelTo, camelTo2, defaultOptions, omitNothingFields, parse)
30+import Data.Aeson.Types (Options(..), Result(Success), ToJSON(..), Value(Null, Object), camelTo, camelTo2, defaultOptions, omitNothingFields, parse)
3131import Data.Char (toUpper)
3232import Data.Either.Compat (isLeft, isRight)
3333import Data.Hashable (hash)
@@ -93,6 +93,7 @@ tests = testGroup "unit" [
9393 , testGroup ".:, .:?, .:!" $ fmap (testCase "-") dotColonMark
9494 , testGroup "JSONPath" $ fmap (testCase "-") jsonPath
9595 , testGroup "Hashable laws" $ fmap (testCase "-") hashableLaws
96+ , testGroup "Object construction" $ fmap (testCase "-") objectConstruction
9697 , testGroup "Issue #351" $ fmap (testCase "-") issue351
9798 , testGroup "Nullary constructors" $ fmap (testCase "-") nullaryConstructors
9899 , testGroup "FromJSONKey" $ fmap (testCase "-") fromJSONKeyAssertions
@@ -302,6 +303,18 @@ hashableLaws = [
302303 a = object ["223" .= False, "807882556" .= True]
303304 b = object ["807882556" .= True, "223" .= False]
304305
306+------------------------------------------------------------------------------
307+-- Check that an alternative way to construct objects works
308+------------------------------------------------------------------------------
309+
310+objectConstruction :: [Assertion]
311+objectConstruction = [
312+ assertEqual "Equal objects constructed differently" recommended notRecommended
313+ ]
314+ where
315+ recommended = object ["foo" .= True, "bar" .= (-1 :: Int)]
316+ notRecommended = Object (mconcat ["foo" .= True, "bar" .= (-1 :: Int)])
317+
305318-------------------------------------------------------------------------------
306319-- ToJSONKey
307320-------------------------------------------------------------------------------