on master help sign in
Fix #72.

Sometimes, it appears, Nullary constructors can be encoded as Null as well as an empty array [not sure why one this!]. The Generic code, as of 49befcafc80a85b371a6e0e0d5ab4ad9b33d8778, fails when a Null is passed for a nullary constructor. Add in a pattern match to fix this issue.

commitc3a1741a2d4b161aea991406979b4c34c0aa2457 authorJared Hance <jaredhance@gmail.com> dateSun 18 Mar 2012, 08:58 (15 years ago) parent5a84330
1 file changed+1
Data/Aeson/Generic.hs+1
Data/Aeson/Generic.hs+1
@@ -290,6 +290,7 @@ parseJSON_generic j = generic
290290 decodeArgs c0 = go (numConstrArgs (resType generic) c0) c0
291291 (constrFields c0)
292292 where
293+ go 0 c _ Null = construct c []
293294 go 1 c [] jd = construct c [jd] -- unary constructor
294295 go _ c [] (Array js) = construct c (V.toList js) -- no field names
295296 -- FIXME? We could allow reading an array into a constructor