Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

omitNothingFields not used in Generic Decode #571

Closed
arianvp opened this issue Jul 25, 2017 · 6 comments
Closed

omitNothingFields not used in Generic Decode #571

arianvp opened this issue Jul 25, 2017 · 6 comments
Assignees
Labels

Comments

@arianvp
Copy link

arianvp commented Jul 25, 2017

omitNothingFields option is used for generic encoding, but it is not used for generic decoding. Is this a bug?

@bergmark
Copy link
Collaborator

Yes that sounds like a bug. Are you able to provide a reproduction?

@Lysxia
Copy link
Collaborator

Lysxia commented Jul 30, 2017

> import Data.Aeson
> data F = F { a :: Maybe Int, b :: Maybe Int } deriving (Show, GHC.Generics.Generic)
> instance FromJSON F where parseJSON = genericParseJSON defaultOptions
> -- omitNothingFields = False by default
> decode "{}" :: Maybe F
Just (F {a = Nothing, b = Nothing})

I guess we want that to fail?

@bergmark
Copy link
Collaborator

bergmark commented Aug 2, 2017

Whoops big typo in my deleted comment! I'm not sure if we should consider this a bug as

> eitherDecode "{\"a\":null,\"b\":null}" :: Either String F
Right (F {a = Nothing, b = Nothing})

Does it hurt that parsing is more lenient?

@bergmark
Copy link
Collaborator

Coming back to this, I think it's a good thing that parsing is more lenient. I'd be open to add this as a part of Options so you can opt-in if you want it.

@phadej phadej self-assigned this Jun 12, 2023
@phadej
Copy link
Collaborator

phadej commented Jun 12, 2023

With #1039 this will fail.

I will first add a test to master to see how things work now, and then decide what to do in #1039.

phadej added a commit that referenced this issue Jun 13, 2023
phadej added a commit that referenced this issue Jun 13, 2023
Add a regression test for issue #571
@phadej
Copy link
Collaborator

phadej commented Jun 14, 2023

#1039 will add allowOmittedFields option (True by default) to control whether omitted fields are ok when parsing.

phadej added a commit that referenced this issue Jun 15, 2023
- Add combinators for using omit* stuff in manually written instances
- Add Manual tests
- Cleanup OptionalFields.Common
- Fix TH and Generics
- Add combinators ToJSON1/2 and FromJSON1/2
- Const, Identity, Tagged and other newtypes
- Fix #687. ToJSON1 respects omitting fields
- Fix #571. Introduce allowOmittedFields to Generics/TH options.
- Resolve #792. () and Proxy can be omitted
phadej added a commit that referenced this issue Jun 15, 2023
- Add combinators for using omit* stuff in manually written instances
- Add Manual tests
- Cleanup OptionalFields.Common
- Fix TH and Generics
- Add combinators ToJSON1/2 and FromJSON1/2
- Const, Identity, Tagged and other newtypes
- Fix #687. ToJSON1 respects omitting fields
- Fix #571. Introduce allowOmittedFields to Generics/TH options.
- Resolve #792. () and Proxy can be omitted
phadej added a commit that referenced this issue Jun 15, 2023
- Add combinators for using omit* stuff in manually written instances
- Add Manual tests
- Cleanup OptionalFields.Common
- Fix TH and Generics
- Add combinators ToJSON1/2 and FromJSON1/2
- Const, Identity, Tagged and other newtypes
- Fix #687. ToJSON1 respects omitting fields
- Fix #571. Introduce allowOmittedFields to Generics/TH options.
- Resolve #792. () and Proxy can be omitted
@phadej phadej closed this as completed in b06eb2c Jun 19, 2023
JonathanLorimer pushed a commit to JonathanLorimer/aeson that referenced this issue Aug 7, 2023
JonathanLorimer pushed a commit to JonathanLorimer/aeson that referenced this issue Aug 7, 2023
- Add combinators for using omit* stuff in manually written instances
- Add Manual tests
- Cleanup OptionalFields.Common
- Fix TH and Generics
- Add combinators ToJSON1/2 and FromJSON1/2
- Const, Identity, Tagged and other newtypes
- Fix haskell#687. ToJSON1 respects omitting fields
- Fix haskell#571. Introduce allowOmittedFields to Generics/TH options.
- Resolve haskell#792. () and Proxy can be omitted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants