decodeJSON :: AE.FromJSON a => LBS.ByteString -> Result a
decodeJSON b =
  case AP.parse (fmap AE.fromJSON AE.json) (lbsToBs b) of
    AP.Done _ (AE.Success g) -> Success g
    AP.Done _ (AE.Error msg) -> Error msg
    AP.Fail _ _ msg -> Error msg
    AP.Partial _ -> Error "JSON is too short"
  where lbsToBs = BS.concat . LBS.toChunks
decodeJSON :: AE.FromJSON a => LBS.ByteString -> Result a
decodeJSON b =
  case AP.parse (fmap AE.fromJSON AE.json) (lbsToBs b) of
    AP.Done _ (AE.Success g) -> Success g
    AP.Done _ (AE.Error msg) -> Error msg
    AP.Fail _ _ msg -> Error msg
    AP.Partial _ -> Error "JSON is too short"
  where lbsToBs = BS.concat . LBS.toChunks
decodeJSON b =
  case AP.parse (fmap AE.fromJSON AE.json) (lbsToBs b) of
    AP.Done _ (AE.Success g) -> Success g
    AP.Done _ (AE.Error msg) -> Error msg
    AP.Fail _ _ msg -> Error msg
    AP.Partial _ -> Error "JSON is too short"
  where lbsToBs = BS.concat . LBS.toChunks