@@ -5,7 +5,7 @@ import Control.Arrow (first)
5import Control.Applicative
5import Control.Applicative
6import Data.Aeson
6import Data.Aeson
7import Data.Aeson.TH
7import Data.Aeson.TH
8−import Data.Aeson.Types (Parser)
8+import Data.Aeson.Types (Parser, Pair)
9import Data.Char
9import Data.Char
10import Data.Hashable (Hashable)
10import Data.Hashable (Hashable)
11import Data.HashMap.Strict (HashMap)
11import Data.HashMap.Strict (HashMap)
@@ -69,3 +69,8 @@ genericParseJSONWithSub _ _ _ = error "impossible"
69(<+>) :: Value -> Value -> Value
69(<+>) :: Value -> Value -> Value
70Object x <+> Object y = Object (x <> y)
70Object x <+> Object y = Object (x <> y)
71_ <+> _ = error "impossible"
71_ <+> _ = error "impossible"
73+withDefaults :: (Value -> Parser a) -> [Pair] -> Value -> Parser a
74+withDefaults parser defs json@(Object _) = parser (json <+> object defs)
75+withDefaults _ _ _ = empty