1For the latest version of this document, please see [https://github.com/bos/aeson/blob/master/changelog.md](https://github.com/bos/aeson/blob/master/changelog.md).
5* The operators for parsing fields now have named aliases:
7 - `.:?` => `parseFieldMaybe`
8 - `.:!` => `parseFieldMaybe'`
9 - These functions now also have variants with explicit parser functions: `explicitParseField`, `explicitParseFieldMaybe`, "explicitParseFieldMaybe'`
10Thanks to Oleg Grenrus.
12* `ToJSONKey (Identity a)` and `FromJSONKey (Identity a)` no longer require the unnecessary `FromJSON a` constraint. Thanks to Oleg Grenrus.
14* Added `Data.Aeson.Encoding.pair'` which is a more general version of `Data.Aeson.Encoding.pair`. Thanks to Andrew Martin.
16* `Day`s BCE are properly encoded and `+` is now a valid prefix for `Day`s CE. Thanks to Matt Parsons.
18* Some commonly used ToJSON instances are now specialized in order to improve compile time. Thanks to Bartosz Nitka.
21[JSONTestSuite](https://github.com/nst/JSONTestSuite) cleanups, all
22motivated by tighter RFC 7159 compliance:
24* The parser now rejects numbers for which
25 [the integer portion contains a leading zero](https://github.com/bos/aeson/commit/3fb7c155f2255482b1b9566ec5c1eaf9895d630e).
26* The parser now rejects numbers for which
27 [a decimal point is not followed by at least one digit](https://github.com/bos/aeson/commit/ecfca35a45286dbe2bbaf5f62354be393bc59b66),
28* The parser now rejects documents that contain [whitespace outside the
29 set {space, newline, carriage return, tab}](https://github.com/bos/aeson/commit/8ef622c2ad8d4a109884e17c2792238a2a320e44).
31Over 90% of JSONTestSuite tests currently pass. The remainder can be
32categorised as follows:
34* The string parser is strict with Unicode compliance where the RFC
35 leaves room for implementation-defined behaviour (tests prefixed
36 with "`i_string_`". (This is necessary because the `text` library
37 cannot accommodate invalid Unicode.)
39* The parser does not (and will not) support UTF-16, UTF-32, or byte
41* The parser accepts unescaped control characters, even though the RFC
42 states that control characters must be escaped. (This may change at
43 some point, but doesn't seem important.)
47* Fixes a regression where a bunch of valid characters caused an
48 "Invalid UTF8-Stream" error when decoding. Thanks to Vladimir
49 Shabanov who investigated and fixed this.
53* Fixes a regression where it was no longer possible to derive
54 instances for types such as `data T a = T { f1 :: a, f2 :: Maybe a
57Thanks to Sean Leather for fixing this, and to Ryan Scott for helping out.
61* Decoding performance has been significantly improved (see
62 https://github.com/bos/aeson/pull/452). Thanks to @winterland1989.
64* Add `ToJSON`/`FromJSON` instances for newtypes from
65 `Data.Semigroup`: `Min`, `Max`, `First`, `Last`, `WrappedMonoid`,
66 `Option`. Thanks to Lennart Spitzner.
68* Make the documentation for `.:!` more accurate. Thanks to Ian Jeffries.
74* Introduced new `FromJSONKey` and `ToJSONKey` type classes that are
75 used to encode maps without going through HashMap. This also allows arbitrary
76 serialization of keys where a string-like key will encode into an object and
77 other keys will encode into an array of key-value tuples.
79* Added higher rank classes: `ToJSON1`, `ToJSON2`, `FromJSON1`, and
82* Added `Data.Aeson.Encoding` with functions to safely write `ToJSON`
83 instances using `toEncoding`.
87* A Cabal `fast` flag was added to disable building with optimizations. This drastically speeds up compiling both aeson ***and*** libraries using aeson so it is recommended to enable it during development. With cabal-install you can `cabal install aeson -ffast` and with stack you can add a flag section to your stack.yaml:
94* Added list specific members to `ToJSON` and `FromJSON` classes. In
95 the same way `Read` and `Show` handle lists specifically. This
96 removes need for overlapping instances to handle `String`.
98* Added a new `sumEncoding` option `UntaggedValue` which prevents
99 objects from being tagged with the constructor name.
101* JSONPaths are now tracked in instances derived with template-haskell
104* Get rid of redundancy of JSONPath error messages in nested records.
106 `eitherDecode "{\"x\":{\"a\": [1,2,true]}}" :: Either String Y`
108 `Error in $.x.a[2]: failed to parse field" x: failed to parse field a: expected Int, encountered Boolean`
109 and now yields `Error in $.x.a[2]: expected Int, encountered Boolean"`.
111 Some users might prefer to insert `modifyFailure` themselves to
112 customize error messages, which previously prevented the use of
115* Backwards compatibility with `bytestring-0.9` using the
116 `bytestring-builder` compatibility package.
118* Export `decodeWith`, `decodeStrictWith`, `eitherDecodeWith`, and
119 `eitherDecodeStrictWith` from `Data.Aeson.Parser`. This allows
120 decoding using explicit parsers instead of using `FromJSON`
123* Un-orphan internal instances to render them in haddocks.
127* Integral `FromJSON` instances now only accept integral
128 values. E.g. parsing `3.14` to `Int` fails instead of succeeding
131* Over/underflows are now caught for bounded numeric types.
133* Remove the `contents` field encoding with `allNullaryToStringTag = False`,
134 giving us `{ "tag" : "c1" }` instead of `{ "tag" : "c1", contents : [] }`.
135 The contents field is optional when parsing so this is only a breaking
136 change for ToJSON instances.
138* Fix a bug where `genericToEncoding` with `unwrapUnaryRecords = True`
139 would produce an invalid encoding: `"unwrap\":""`.
141* `ToJSON` instances using `genericToEncoding` and `omitNothingFields`
142 no longer produce invalid JSON.
144* Added instances for `DList`, `Compose`, `Product`, `Sum`.
148* Enable `PolyKinds` to generalize `Proxy`, `Tagged`, and `Const` instances.
149* Add `unsafeToEncoding` in `Data.Aeson.Types`, use with care!
153* Fix build with `base >= 4.8` and `unordered-containers < 0.2.6`.
157* Fix build on TH-less GHCs
161* Fix build with `base < 4.8` and `unordered-containers < 0.2.6`.
162* Add missing field in docs for `defaultOptions`.
166* Fixes a bug where the hashes of equal values could differ.
170The only changes are added instances.
173* `ToJSON a => ToJSON (NonEmpty a)`
174* `FromJSON a => FromJSON (NonEmpty a)`
176* `FromJSON (Proxy a)`
177* `ToJSON b => ToJSON (Tagged a b)`
178* `FromJSON b => FromJSON (Tagged a b)`
179* `ToJSON a => ToJSON (Const a b)`
180* `FromJSON a => FromJSON (Const a b)`
182These are now available for older GHCs:
188This release should be close to backwards compatible with aeson 0.9.
190If you are upgrading from aeson 0.10 it might be easier to go back in
191history to the point you were still using 0.9.
195* Revert `.:?` to behave like it did in 0.9. If you want the 0.10
196 behavior use `.:!` instead.
198* Revert JSON format of `Either` to 0.9, `Left` and `Right` are now
199 serialized with an initial uppercase letter. If you want the names
200 in lowercase you can add a newtype with an instance.
202* All `ToJSON` and `FromJSON` instances except for `[a]` are no longer
203 `OVERLAPPABLE`. Mark your instance as `OVERLAPPING` if it overlaps
204 any of the other aeson instances.
206* All `ToJSON` and `FromJSON` instances except for `[Char]` are no
207 longer incoherent, this means you may need to replace your
208 incoherent instances with a newtyped instance.
212* Introduce `.:!` that behaves like `.:?` did in 0.10.
214* Allow `HH:MM` format for `ZonedTime` and `UTCTime`.
215 This is one of the formats allowed by
216 [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#Times).
218* Added `ToJSON` and `FromJSON` instances for the
219 `Version`, `Ordering`, and `Natural` types.
223* JSONPath identifiers are now escaped if they contain invalid characters.
225* Fixed JSONPath messages for Seq to include indices.
227* Fixed JSONPath messages for Either to include `left`/`right`.
229* Fix missing quotes surrounding time encodings.
231* Fix #293: Type error in TH when using `omitNothingFields = True`.
235* Various updates to support GHC 8.
240## Performance improvements
242* Direct encoding via the new `toEncoding` method is over 2x faster
243 than `toJSON`. (You must write or code-gen a `toEncoding`
244 implementation to unlock this speedup. See below for details.)
246* Improved string decoding gives a 12% speed win in parsing
247 string-heavy JSON payloads (very common).
249* Encoding and decoding of time-related types are 10x faster (!!) as a
250 result of bypassing `Data.Time.Format` and the arbitrary-precision
253* When using `toEncoding`, `[Char]` can be encoded without a conversion to
254 `Text`. This is fast and efficient.
256* Parsing into an `Object` is now 5% faster and more
257 allocation-efficient.
259## SUBTLE API CHANGES, READ CAREFULLY
261With the exception of long-deprecated code, the API changes below
262**should be upwards compatible** from older versions of `aeson`. If you run
263into upgrade problems, please file an issue with details.
265* The `ToJSON` class has a new method, `toEncoding`, that allows
266 direct encoding from a Haskell value to a lazy bytestring without
267 construction of an intermediate `Value`.
269 The performance benefits of direct encoding are significant: more
270 than 2x faster than before, with less than 1/3 the memory usage.
272 To preserve API compatibility across upgrades from older versions of
273 this library, the default implementation of `toEncoding` uses
274 `toJSON`. You will *not* see any performance improvement unless you
275 write an implementation of `toEncoding`, which can be very simple:
278 instance ToJSON Coord where
279 toEncoding = genericToEncoding defaultOptions
282 (Behind the scenes, the `encode` function uses `toEncoding` now, so
283 if you implement `toEncoding` for your types, you should see a
284 speedup immediately.)
286 If you use Template Haskell or GHC Generics to auto-generate your
287 `ToJSON` instances, you'll benefit from fast toEncoding
288 implementations for free!
290* When converting from a `Value` to a target Haskell type, `FromJSON`
291 instances now provide much better error messages, including a
292 complete JSON path from the root of the object to the offending
293 element. This greatly eases debugging.
295* It is now possible to use Template Haskell to generate `FromJSON`
296 and `ToJSON` instances for types in data families.
298* If you use Template Haskell or generics, and used to use the
299 `camelTo` function to rename fields, the new `camelTo2` function is
300 smarter. For example, `camelTo` will rename `CamelAPICase` to
301 `camelapi_case` (ugh!), while `camelTo2` will map it to
302 `camel_api_case` (yay!).
304* New `ToJSON` and `FromJSON` instances for the following time-related
305 types: `Day`, `LocalTime`.
307* `FromJSON` `UTCTime` parser accepts the same values as for `ZonedTime`,
308 but converts any time zone offset into a UTC time.
310* The `Result` type is now an instance of `Foldable` and `Traversable`.
312* The `Data.Aeson.Generic` module has been removed. It was deprecated in
315* GHC 7.2 and older are no longer supported.
317* The instance of `Monad` for the `Result` type lacked an implementation
318 of `fail` (oops). This has been corrected.
320* Semantics of `(.:?)` operator are changed. It's doesn't anymore accept
321 present `Null` value.
323* Added `(Foldable t, ToJSON a) => ToJSON (t a)` overlappable instance.
324 You might see `No instance for (Foldable YourPolymorphicType) arising from a
325 use of ‘.=’` -errors due this change.
329* A stray export of `encodeToBuilder` got away!
333* The `json` and `json'` parsers are now synonyms for `value` and
334 `value'`, in conformance with the looser semantics of RFC 7159.
336* Renamed `encodeToByteStringBuilder` to the more compact
341* The dependency on the `unordered-containers` package was too lax,
342 and has been corrected.
346* Encoding a `Scientific` value with a huge exponent is now handled
347 efficiently. (This would previously allocate a huge
348 arbitrary-precision integer, potentially leading to a denial of
351* Handling of strings that contain backslash escape sequences is
352 greatly improved. For a pathological string containing almost a
353 megabyte of consecutive backslashes, the new implementation is 27x
354 faster and uses 42x less memory.
356* The `ToJSON` instance for `UTCTime` is rendered with higher
357 (picosecond) resolution.
359* The `value` parser now correctly handles leading whitespace.
361* New instances of `ToJSON` and `FromJSON` for `Data.Sequence` and
362 `Data.Functor.Identity`. The `Value` type now has a `Read` instance.
364* `ZonedTime` parser ordering now favours the standard `JSON` format,
365 increasing efficiency in the common case.
367* Encoding to a `Text.Builder` now escapes `'<'` and `'>'` characters,
372* Fix `ToJSON` instance for 15-tuples (see #223).
380* Add `ToJSON` and `FromJSON` instances for tuples of up to 15
385* Major compiler and library compatibility changes: we have dropped
386 support for GHC older than 7.4, `text` older than 1.1, and
387 `bytestring` older than 0.10.4.0. Supporting the older versions had
388 become increasingly difficult, to the point where it was no longer
393* The performance of encoding to and decoding of bytestrings have both
394 improved by up to 2x, while also using less memory.
396* New dependency: the `scientific` package lets us parse floating point
397 numbers more quickly and accurately.
399* `eitherDecode`, `decodeStrictWith`: fixed bugs.
401* Added `FromJSON` and `ToJSON` instances for `Tree` and `Scientific`.
403* Fixed the `ToJSON` instances for `UTCTime` and `ZonedTime`.
407* Much improved documentation.
409* Angle brackets are now escaped in JSON strings, to help avoid XSS
412* Fixed up handling of nullary constructors when using generic
415* Added `ToJSON`/`FromJSON` instances for:
418 * ISO-8601 dates: `UTCTime`, `ZonedTime`, and `TimeZone`
420* Added accessor functions for inspecting `Value`s.
422* Added `eitherDecode` function that returns an error message if
427* This release introduces a slightly obscure, but
428 backwards-incompatible, change.
430 In the generic APIs of versions 0.4 and 0.5, fields whose names
431 began with a `"_"` character would have this character removed. This
432 no longer occurs, as it was both buggy and surprising
433 (https://github.com/bos/aeson/issues/53).
435* Fixed a bug in generic decoding of nullary constructors
436 (https://github.com/bos/aeson/issues/62).
440* When used with the UTF-8 encoding performance improvements
441 introduced in version 0.11.1.12 of the `text` package, this release
442 improves `aeson`'s JSON encoding performance by 33% relative to
445 As part of achieving this improvement, an API change was necessary.
446 The `fromValue` function in the `Data.Aeson.Encode` module now uses
447 the `text` package's `Builder` type instead of the `blaze-builder`
448 package's `Builder` type.
452* The new `decode` function complements the longstanding `encode`
453 function, and makes the API simpler.
455* New examples make it easier to learn to use the package
456 (https://github.com/bos/aeson/tree/master/examples).
460 `aeson`'s support for data-type generic programming makes it
461 possible to use JSON encodings of most data types without writing
462 any boilerplate instances.
464 Thanks to Bas Van Dijk, `aeson` now supports the two major schemes
465 for doing datatype-generic programming:
467 * the modern mechanism, built into GHC itself
468 (http://www.haskell.org/ghc/docs/latest/html/users_guide/generic-programming.html)
470 * the older mechanism, based on SYB (aka "scrap your
473 The modern GHC-based generic mechanism is fast and terse: in fact,
474 its performance is generally comparable in performance to
475 hand-written and TH-derived `ToJSON` and `FromJSON` instances. To
476 see how to use GHC generics, refer to `examples/Generic.hs`.
478 The SYB-based generics support lives in `Data.Aeson.Generic` and is
479 provided mainly for users of GHC older than 7.2. SYB is far slower
480 (by about 10x) than the more modern generic mechanism. To see how
481 to use SYB generics, refer to `examples/GenericSYB.hs`.
483* We switched the intermediate representation of JSON objects from
484 `Data.Map` to `Data.HashMap` which has improved type conversion
487* Instances of `ToJSON` and `FromJSON` for tuples are between 45% and 70%
492 This version of aeson makes explicit the decoupling between
493 *identifying* an element of a JSON document and *converting* it to
494 Haskell. See the `Data.Aeson.Parser` documentation for details.
496 The normal `aeson` `decode` function performs identification
497 strictly, but defers conversion until needed. This can result in
498 improved performance (e.g. if the results of some conversions are
499 never needed), but at a cost in increased memory consumption.
501 The new `decode'` function performs identification and conversion
502 immediately. This incurs an up-front cost in CPU cycles, but
503 reduces reduce memory consumption.
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list