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
Add possiblity to specify default values for for record fields: #231
Conversation
Added an instance for the 'Fixed' class.
parseJSON for the variations on ISO-8601 dates as listed in ECMA-262.
Add functions for inspecting Values
Added eitherDecode and eitherDecode'
Add elaborate guide to Data.Aeson's Haddock documentation
De-emphasize working directly with the Value type as this is not the common (or recommended) way to use the library, but still include documentation on how to use it when it's called for. Since the documentation on using generics is documented in the FromJSON and ToJSON classes, refer to that documentation instead of only documenting one method (which is not the preferred method anymore with default signatures I believe).
Improve introductionary documentation
Add support for specifying how to encode datatypes in Data.Aeson.TH
--HG-- extra : amend_source : d48e612e53488f41b0d6f2ceb4395978b48d411d
--HG-- extra : amend_source : aa3ad961a2c62e2948ee0e213615c01ac002b42c
This is more portable between compilers as well as between variants on GHC (ex: HaLVM is building off of head so GHC appears as 7.8.3 while TH is 2.10).
Data.Aeson.Types.Instances: fix UTCTime for years outside of [0, 9999]
Modernizing the TH example.
Export 'camelTo' function and fix its tests
Say we want to derive: data GGResult = GGResult { _ggrtPartialMatch :: Bool } deriving (Show, Typeable) deriveJSON defaultOptions { fieldLabelModifier = fromCamel 5 , fieldsWithDefaults = [ ("partial_match", [| False |]) ] } ''GGResult Now whenever parser was expecting field "partial_match" inside JSON file, will not fail but return a value `False`.
Hi, One can specify new value inside Oxford brackets |
Thanks, I like the feature! Is there a possibility you can also build this into the GHC.Generics decoders? |
I did not play with Generics, but would have doubts if one can only specify values for one field of constructor (or just one constructor) and having all other parts derived. Or override only some patterns or generated implementations. If only we had something like [ http://en.wikipedia.org/wiki/Pattern_calculus ]. |
Oh I see that the Can't we have an interface which is TH agnostic? For example: fieldsWithDefaults :: [(String, Dynamic)] Then in the If this will be a TH-only feature we should clearly document that because currently both the |
If we mix TH + Generics it still works
This TH will complain at the compile time if there is a type mismatch. I am not so well wersed in Dynamic or Generics to know, how they behave. I will look later how to do it with Dynamic, so it is gone once the code is compiled. |
Say we want to derive:
Now whenever parser was expecting field
"partial_match"
inside JSON file but it is not there, the parser will not fail but return a valueFalse
.