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* Decoding performance has been significantly improved (see
6 https://github.com/bos/aeson/pull/452).
8* Add `ToJSON`/`FromJSON` instances for newtypes from
9 `Data.Semigroup`: `Min`, `Max`, `First`, `Last`, `WrappedMonoid`,
12* Make the documentation for `.:!` more accurate.
18* Introduced new `FromJSONKey` and `ToJSONKey` type classes that are
19 used to encode maps without going through HashMap. This also allows arbitrary
20 serialization of keys where a string-like key will encode into an object and
21 other keys will encode into an array of key-value tuples.
23* Added higher rank classes: `ToJSON1`, `ToJSON2`, `FromJSON1`, and
26* Added `Data.Aeson.Encoding` with functions to safely write `ToJSON`
27 instances using `toEncoding`.
31* 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:
38* Added list specific members to `ToJSON` and `FromJSON` classes. In
39 the same way `Read` and `Show` handle lists specifically. This
40 removes need for overlapping instances to handle `String`.
42* Added a new `sumEncoding` option `UntaggedValue` which prevents
43 objects from being tagged with the constructor name.
45* JSONPaths are now tracked in instances derived with template-haskell
48* Get rid of redundancy of JSONPath error messages in nested records.
50 `eitherDecode "{\"x\":{\"a\": [1,2,true]}}" :: Either String Y`
52 `Error in $.x.a[2]: failed to parse field" x: failed to parse field a: expected Int, encountered Boolean`
53 and now yields `Error in $.x.a[2]: expected Int, encountered Boolean"`.
55 Some users might prefer to insert `modifyFailure` themselves to
56 customize error messages, which previously prevented the use of
59* Backwards compatibility with `bytestring-0.9` using the
60 `bytestring-builder` compatibility package.
62* Export `decodeWith`, `decodeStrictWith`, `eitherDecodeWith`, and
63 `eitherDecodeStrictWith` from `Data.Aeson.Parser`. This allows
64 decoding using explicit parsers instead of using `FromJSON`
67* Un-orphan internal instances to render them in haddocks.
71* Integral `FromJSON` instances now only accept integral
72 values. E.g. parsing `3.14` to `Int` fails instead of succeeding
75* Over/underflows are now caught for bounded numeric types.
77* Remove the `contents` field encoding with `allNullaryToStringTag = False`,
78 giving us `{ "tag" : "c1" }` instead of `{ "tag" : "c1", contents : [] }`.
79 The contents field is optional when parsing so this is only a breaking
80 change for ToJSON instances.
82* Fix a bug where `genericToEncoding` with `unwrapUnaryRecords = True`
83 would produce an invalid encoding: `"unwrap\":""`.
85* `ToJSON` instances using `genericToEncoding` and `omitNothingFields`
86 no longer produce invalid JSON.
88* Added instances for `DList`, `Compose`, `Product`, `Sum`.
92* Enable `PolyKinds` to generalize `Proxy`, `Tagged`, and `Const` instances.
93* Add `unsafeToEncoding` in `Data.Aeson.Types`, use with care!
97* Fix build with `base >= 4.8` and `unordered-containers < 0.2.6`.
101* Fix build on TH-less GHCs
105* Fix build with `base < 4.8` and `unordered-containers < 0.2.6`.
106* Add missing field in docs for `defaultOptions`.
110* Fixes a bug where the hashes of equal values could differ.
114The only changes are added instances.
117* `ToJSON a => ToJSON (NonEmpty a)`
118* `FromJSON a => FromJSON (NonEmpty a)`
120* `FromJSON (Proxy a)`
121* `ToJSON b => ToJSON (Tagged a b)`
122* `FromJSON b => FromJSON (Tagged a b)`
123* `ToJSON a => ToJSON (Const a b)`
124* `FromJSON a => FromJSON (Const a b)`
126These are now available for older GHCs:
132This release should be close to backwards compatible with aeson 0.9.
134If you are upgrading from aeson 0.10 it might be easier to go back in
135history to the point you were still using 0.9.
139* Revert `.:?` to behave like it did in 0.9. If you want the 0.10
140 behavior use `.:!` instead.
142* Revert JSON format of `Either` to 0.9, `Left` and `Right` are now
143 serialized with an initial uppercase letter. If you want the names
144 in lowercase you can add a newtype with an instance.
146* All `ToJSON` and `FromJSON` instances except for `[a]` are no longer
147 `OVERLAPPABLE`. Mark your instance as `OVERLAPPING` if it overlaps
148 any of the other aeson instances.
150* All `ToJSON` and `FromJSON` instances except for `[Char]` are no
151 longer incoherent, this means you may need to replace your
152 incoherent instances with a newtyped instance.
156* Introduce `.:!` that behaves like `.:?` did in 0.10.
158* Allow `HH:MM` format for `ZonedTime` and `UTCTime`.
159 This is one of the formats allowed by
160 [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#Times).
162* Added `ToJSON` and `FromJSON` instances for the
163 `Version`, `Ordering`, and `Natural` types.
167* JSONPath identifiers are now escaped if they contain invalid characters.
169* Fixed JSONPath messages for Seq to include indices.
171* Fixed JSONPath messages for Either to include `left`/`right`.
173* Fix missing quotes surrounding time encodings.
175* Fix #293: Type error in TH when using `omitNothingFields = True`.
179* Various updates to support GHC 8.
184## Performance improvements
186* Direct encoding via the new `toEncoding` method is over 2x faster
187 than `toJSON`. (You must write or code-gen a `toEncoding`
188 implementation to unlock this speedup. See below for details.)
190* Improved string decoding gives a 12% speed win in parsing
191 string-heavy JSON payloads (very common).
193* Encoding and decoding of time-related types are 10x faster (!!) as a
194 result of bypassing `Data.Time.Format` and the arbitrary-precision
197* When using `toEncoding`, `[Char]` can be encoded without a conversion to
198 `Text`. This is fast and efficient.
200* Parsing into an `Object` is now 5% faster and more
201 allocation-efficient.
203## SUBTLE API CHANGES, READ CAREFULLY
205With the exception of long-deprecated code, the API changes below
206**should be upwards compatible** from older versions of `aeson`. If you run
207into upgrade problems, please file an issue with details.
209* The `ToJSON` class has a new method, `toEncoding`, that allows
210 direct encoding from a Haskell value to a lazy bytestring without
211 construction of an intermediate `Value`.
213 The performance benefits of direct encoding are significant: more
214 than 2x faster than before, with less than 1/3 the memory usage.
216 To preserve API compatibility across upgrades from older versions of
217 this library, the default implementation of `toEncoding` uses
218 `toJSON`. You will *not* see any performance improvement unless you
219 write an implementation of `toEncoding`, which can be very simple:
222 instance ToJSON Coord where
223 toEncoding = genericToEncoding defaultOptions
226 (Behind the scenes, the `encode` function uses `toEncoding` now, so
227 if you implement `toEncoding` for your types, you should see a
228 speedup immediately.)
230 If you use Template Haskell or GHC Generics to auto-generate your
231 `ToJSON` instances, you'll benefit from fast toEncoding
232 implementations for free!
234* When converting from a `Value` to a target Haskell type, `FromJSON`
235 instances now provide much better error messages, including a
236 complete JSON path from the root of the object to the offending
237 element. This greatly eases debugging.
239* It is now possible to use Template Haskell to generate `FromJSON`
240 and `ToJSON` instances for types in data families.
242* If you use Template Haskell or generics, and used to use the
243 `camelTo` function to rename fields, the new `camelTo2` function is
244 smarter. For example, `camelTo` will rename `CamelAPICase` to
245 `camelapi_case` (ugh!), while `camelTo2` will map it to
246 `camel_api_case` (yay!).
248* New `ToJSON` and `FromJSON` instances for the following time-related
249 types: `Day`, `LocalTime`.
251* `FromJSON` `UTCTime` parser accepts the same values as for `ZonedTime`,
252 but converts any time zone offset into a UTC time.
254* The `Result` type is now an instance of `Foldable` and `Traversable`.
256* The `Data.Aeson.Generic` module has been removed. It was deprecated in
259* GHC 7.2 and older are no longer supported.
261* The instance of `Monad` for the `Result` type lacked an implementation
262 of `fail` (oops). This has been corrected.
264* Semantics of `(.:?)` operator are changed. It's doesn't anymore accept
265 present `Null` value.
267* Added `(Foldable t, ToJSON a) => ToJSON (t a)` overlappable instance.
268 You might see `No instance for (Foldable YourPolymorphicType) arising from a
269 use of ‘.=’` -errors due this change.
273* A stray export of `encodeToBuilder` got away!
277* The `json` and `json'` parsers are now synonyms for `value` and
278 `value'`, in conformance with the looser semantics of RFC 7159.
280* Renamed `encodeToByteStringBuilder` to the more compact
285* The dependency on the `unordered-containers` package was too lax,
286 and has been corrected.
290* Encoding a `Scientific` value with a huge exponent is now handled
291 efficiently. (This would previously allocate a huge
292 arbitrary-precision integer, potentially leading to a denial of
295* Handling of strings that contain backslash escape sequences is
296 greatly improved. For a pathological string containing almost a
297 megabyte of consecutive backslashes, the new implementation is 27x
298 faster and uses 42x less memory.
300* The `ToJSON` instance for `UTCTime` is rendered with higher
301 (picosecond) resolution.
303* The `value` parser now correctly handles leading whitespace.
305* New instances of `ToJSON` and `FromJSON` for `Data.Sequence` and
306 `Data.Functor.Identity`. The `Value` type now has a `Read` instance.
308* `ZonedTime` parser ordering now favours the standard `JSON` format,
309 increasing efficiency in the common case.
311* Encoding to a `Text.Builder` now escapes `'<'` and `'>'` characters,
316* Fix `ToJSON` instance for 15-tuples (see #223).
324* Add `ToJSON` and `FromJSON` instances for tuples of up to 15
329* Major compiler and library compatibility changes: we have dropped
330 support for GHC older than 7.4, `text` older than 1.1, and
331 `bytestring` older than 0.10.4.0. Supporting the older versions had
332 become increasingly difficult, to the point where it was no longer
337* The performance of encoding to and decoding of bytestrings have both
338 improved by up to 2x, while also using less memory.
340* New dependency: the `scientific` package lets us parse floating point
341 numbers more quickly and accurately.
343* `eitherDecode`, `decodeStrictWith`: fixed bugs.
345* Added `FromJSON` and `ToJSON` instances for `Tree` and `Scientific`.
347* Fixed the `ToJSON` instances for `UTCTime` and `ZonedTime`.
351* Much improved documentation.
353* Angle brackets are now escaped in JSON strings, to help avoid XSS
356* Fixed up handling of nullary constructors when using generic
359* Added `ToJSON`/`FromJSON` instances for:
362 * ISO-8601 dates: `UTCTime`, `ZonedTime`, and `TimeZone`
364* Added accessor functions for inspecting `Value`s.
366* Added `eitherDecode` function that returns an error message if
371* This release introduces a slightly obscure, but
372 backwards-incompatible, change.
374 In the generic APIs of versions 0.4 and 0.5, fields whose names
375 began with a `"_"` character would have this character removed. This
376 no longer occurs, as it was both buggy and surprising
377 (https://github.com/bos/aeson/issues/53).
379* Fixed a bug in generic decoding of nullary constructors
380 (https://github.com/bos/aeson/issues/62).
384* When used with the UTF-8 encoding performance improvements
385 introduced in version 0.11.1.12 of the `text` package, this release
386 improves `aeson`'s JSON encoding performance by 33% relative to
389 As part of achieving this improvement, an API change was necessary.
390 The `fromValue` function in the `Data.Aeson.Encode` module now uses
391 the `text` package's `Builder` type instead of the `blaze-builder`
392 package's `Builder` type.
396* The new `decode` function complements the longstanding `encode`
397 function, and makes the API simpler.
399* New examples make it easier to learn to use the package
400 (https://github.com/bos/aeson/tree/master/examples).
404 `aeson`'s support for data-type generic programming makes it
405 possible to use JSON encodings of most data types without writing
406 any boilerplate instances.
408 Thanks to Bas Van Dijk, `aeson` now supports the two major schemes
409 for doing datatype-generic programming:
411 * the modern mechanism, built into GHC itself
412 (http://www.haskell.org/ghc/docs/latest/html/users_guide/generic-programming.html)
414 * the older mechanism, based on SYB (aka "scrap your
417 The modern GHC-based generic mechanism is fast and terse: in fact,
418 its performance is generally comparable in performance to
419 hand-written and TH-derived `ToJSON` and `FromJSON` instances. To
420 see how to use GHC generics, refer to `examples/Generic.hs`.
422 The SYB-based generics support lives in `Data.Aeson.Generic` and is
423 provided mainly for users of GHC older than 7.2. SYB is far slower
424 (by about 10x) than the more modern generic mechanism. To see how
425 to use SYB generics, refer to `examples/GenericSYB.hs`.
427* We switched the intermediate representation of JSON objects from
428 `Data.Map` to `Data.HashMap` which has improved type conversion
431* Instances of `ToJSON` and `FromJSON` for tuples are between 45% and 70%
436 This version of aeson makes explicit the decoupling between
437 *identifying* an element of a JSON document and *converting* it to
438 Haskell. See the `Data.Aeson.Parser` documentation for details.
440 The normal `aeson` `decode` function performs identification
441 strictly, but defers conversion until needed. This can result in
442 improved performance (e.g. if the results of some conversions are
443 never needed), but at a cost in increased memory consumption.
445 The new `decode'` function performs identification and conversion
446 immediately. This incurs an up-front cost in CPU cycles, but
447 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