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* Add `FromJSON` and `ToJSON` instances for
6 * `DiffTime`, thanks to Víctor López Juan.
7 * `CTime`, thanks to Daniel Díaz.
8* Fix handling of fractions when parsing Natural, thanks to Yuriy Syrovetskiy.
9* Change text in error messages for Integral types to make them follow the common pattern, thanks to Yuriy Syrovetskiy.
10* Add missing `INCOHERENT` pragma for `RecordToPair`, thanks to Xia Li-yao.
11* Everything related to `Options` is now exported from `Data.Aeson`, thanks to Xia Li-yao.
12* Optimizations to not escape text in clear cases, thanks to Oleg Grenrus.
13* Some documentation fixes, thanks to Phil de Joux & Xia Li-yao.
17* Add `parserThrowError` and `parserCatchError` combinators, thanks to Oleg Grenrus.
19* Add `Generic` instance for `Value`, thanks to Xia Li-yao.
21* Fix a mistake in the 1.2.0.0 changelog, the `cffi` flag is disabled by default! Thanks to dbaynard.
25* `tagSingleConstructors`, an option to encode single-constructor types as tagged sums was added to `Options`. It is disabled by default for backward compatibility.
27* The `cffi` flag is now turned off (`False`) by default, this means C FFI code is no longer used by default. You can flip the flag to get C implementation.
29* The `Options` constructor is no longer exposed to prevent new options from being breaking changes, use `defaultOptions` instead.
31* The contents of `GToJSON` and `GToEncoding` are no longer exposed.
33* Some INLINE pragmas were removed to avoid GHC running out of simplifier ticks.
37* Fix an accidental change in the format of `deriveJSON`. Thanks to Xia Li-yao!
39* Documentation improvements regarding `ToJSON`, `FromJSON`, and `SumEncoding`. Thanks to Xia Li-yao and Lennart Spitzner!
43* Added a pure implementation of the C FFI code, the C FFI code. If you wish to use the pure haskell version set the `cffi` flag to `False`. This should make aeson compile when C isn't available, such as for GHCJS. Thanks to James Parker & Marcin Tolysz!
45* Using the `fast` flag can no longer cause a test case to fail. As far as we know this didn't affect any users of the library itself. Thanks to Xia Li-yao!
49* Added instances for `UUID`.
51* The operators for parsing fields now have named aliases:
52 - `.:` => `parseField`
53 - `.:?` => `parseFieldMaybe`
54 - `.:!` => `parseFieldMaybe'`
55 - These functions now also have variants with explicit parser functions: `explicitParseField`, `explicitParseFieldMaybe`, "explicitParseFieldMaybe'`
56Thanks to Oleg Grenrus.
58* `ToJSONKey (Identity a)` and `FromJSONKey (Identity a)` no longer require the unnecessary `FromJSON a` constraint. Thanks to Oleg Grenrus.
60* Added `Data.Aeson.Encoding.pair'` which is a more general version of `Data.Aeson.Encoding.pair`. Thanks to Andrew Martin.
62* `Day`s BCE are properly encoded and `+` is now a valid prefix for `Day`s CE. Thanks to Matt Parsons.
64* Some commonly used ToJSON instances are now specialized in order to improve compile time. Thanks to Bartosz Nitka.
67[JSONTestSuite](https://github.com/nst/JSONTestSuite) cleanups, all
68motivated by tighter RFC 7159 compliance:
70* The parser now rejects numbers for which
71 [the integer portion contains a leading zero](https://github.com/bos/aeson/commit/3fb7c155f2255482b1b9566ec5c1eaf9895d630e).
72* The parser now rejects numbers for which
73 [a decimal point is not followed by at least one digit](https://github.com/bos/aeson/commit/ecfca35a45286dbe2bbaf5f62354be393bc59b66),
74* The parser now rejects documents that contain [whitespace outside the
75 set {space, newline, carriage return, tab}](https://github.com/bos/aeson/commit/8ef622c2ad8d4a109884e17c2792238a2a320e44).
77Over 90% of JSONTestSuite tests currently pass. The remainder can be
78categorised as follows:
80* The string parser is strict with Unicode compliance where the RFC
81 leaves room for implementation-defined behaviour (tests prefixed
82 with "`i_string_`". (This is necessary because the `text` library
83 cannot accommodate invalid Unicode.)
85* The parser does not (and will not) support UTF-16, UTF-32, or byte
87* The parser accepts unescaped control characters, even though the RFC
88 states that control characters must be escaped. (This may change at
89 some point, but doesn't seem important.)
93* Fixes a regression where a bunch of valid characters caused an
94 "Invalid UTF8-Stream" error when decoding. Thanks to Vladimir
95 Shabanov who investigated and fixed this.
99* Fixes a regression where it was no longer possible to derive
100 instances for types such as `data T a = T { f1 :: a, f2 :: Maybe a
103Thanks to Sean Leather for fixing this, and to Ryan Scott for helping out.
107* Decoding performance has been significantly improved (see
108 https://github.com/bos/aeson/pull/452). Thanks to @winterland1989.
110* Add `ToJSON`/`FromJSON` instances for newtypes from
111 `Data.Semigroup`: `Min`, `Max`, `First`, `Last`, `WrappedMonoid`,
112 `Option`. Thanks to Lennart Spitzner.
114* Make the documentation for `.:!` more accurate. Thanks to Ian Jeffries.
120* Introduced new `FromJSONKey` and `ToJSONKey` type classes that are
121 used to encode maps without going through HashMap. This also allows arbitrary
122 serialization of keys where a string-like key will encode into an object and
123 other keys will encode into an array of key-value tuples.
125* Added higher rank classes: `ToJSON1`, `ToJSON2`, `FromJSON1`, and
128* Added `Data.Aeson.Encoding` with functions to safely write `ToJSON`
129 instances using `toEncoding`.
133* 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:
140* Added list specific members to `ToJSON` and `FromJSON` classes. In
141 the same way `Read` and `Show` handle lists specifically. This
142 removes need for overlapping instances to handle `String`.
144* Added a new `sumEncoding` option `UntaggedValue` which prevents
145 objects from being tagged with the constructor name.
147* JSONPaths are now tracked in instances derived with template-haskell
150* Get rid of redundancy of JSONPath error messages in nested records.
152 `eitherDecode "{\"x\":{\"a\": [1,2,true]}}" :: Either String Y`
154 `Error in $.x.a[2]: failed to parse field" x: failed to parse field a: expected Int, encountered Boolean`
155 and now yields `Error in $.x.a[2]: expected Int, encountered Boolean"`.
157 Some users might prefer to insert `modifyFailure` themselves to
158 customize error messages, which previously prevented the use of
161* Backwards compatibility with `bytestring-0.9` using the
162 `bytestring-builder` compatibility package.
164* Export `decodeWith`, `decodeStrictWith`, `eitherDecodeWith`, and
165 `eitherDecodeStrictWith` from `Data.Aeson.Parser`. This allows
166 decoding using explicit parsers instead of using `FromJSON`
169* Un-orphan internal instances to render them in haddocks.
173* Integral `FromJSON` instances now only accept integral
174 values. E.g. parsing `3.14` to `Int` fails instead of succeeding
177* Over/underflows are now caught for bounded numeric types.
179* Remove the `contents` field encoding with `allNullaryToStringTag = False`,
180 giving us `{ "tag" : "c1" }` instead of `{ "tag" : "c1", contents : [] }`.
181 The contents field is optional when parsing so this is only a breaking
182 change for ToJSON instances.
184* Fix a bug where `genericToEncoding` with `unwrapUnaryRecords = True`
185 would produce an invalid encoding: `"unwrap\":""`.
187* `ToJSON` instances using `genericToEncoding` and `omitNothingFields`
188 no longer produce invalid JSON.
190* Added instances for `DList`, `Compose`, `Product`, `Sum`.
194* Enable `PolyKinds` to generalize `Proxy`, `Tagged`, and `Const` instances.
195* Add `unsafeToEncoding` in `Data.Aeson.Types`, use with care!
199* Fix build with `base >= 4.8` and `unordered-containers < 0.2.6`.
203* Fix build on TH-less GHCs
207* Fix build with `base < 4.8` and `unordered-containers < 0.2.6`.
208* Add missing field in docs for `defaultOptions`.
212* Fixes a bug where the hashes of equal values could differ.
216The only changes are added instances.
219* `ToJSON a => ToJSON (NonEmpty a)`
220* `FromJSON a => FromJSON (NonEmpty a)`
222* `FromJSON (Proxy a)`
223* `ToJSON b => ToJSON (Tagged a b)`
224* `FromJSON b => FromJSON (Tagged a b)`
225* `ToJSON a => ToJSON (Const a b)`
226* `FromJSON a => FromJSON (Const a b)`
228These are now available for older GHCs:
234This release should be close to backwards compatible with aeson 0.9.
236If you are upgrading from aeson 0.10 it might be easier to go back in
237history to the point you were still using 0.9.
241* Revert `.:?` to behave like it did in 0.9. If you want the 0.10
242 behavior use `.:!` instead.
244* Revert JSON format of `Either` to 0.9, `Left` and `Right` are now
245 serialized with an initial uppercase letter. If you want the names
246 in lowercase you can add a newtype with an instance.
248* All `ToJSON` and `FromJSON` instances except for `[a]` are no longer
249 `OVERLAPPABLE`. Mark your instance as `OVERLAPPING` if it overlaps
250 any of the other aeson instances.
252* All `ToJSON` and `FromJSON` instances except for `[Char]` are no
253 longer incoherent, this means you may need to replace your
254 incoherent instances with a newtyped instance.
258* Introduce `.:!` that behaves like `.:?` did in 0.10.
260* Allow `HH:MM` format for `ZonedTime` and `UTCTime`.
261 This is one of the formats allowed by
262 [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#Times).
264* Added `ToJSON` and `FromJSON` instances for the
265 `Version`, `Ordering`, and `Natural` types.
269* JSONPath identifiers are now escaped if they contain invalid characters.
271* Fixed JSONPath messages for Seq to include indices.
273* Fixed JSONPath messages for Either to include `left`/`right`.
275* Fix missing quotes surrounding time encodings.
277* Fix #293: Type error in TH when using `omitNothingFields = True`.
281* Various updates to support GHC 8.
286## Performance improvements
288* Direct encoding via the new `toEncoding` method is over 2x faster
289 than `toJSON`. (You must write or code-gen a `toEncoding`
290 implementation to unlock this speedup. See below for details.)
292* Improved string decoding gives a 12% speed win in parsing
293 string-heavy JSON payloads (very common).
295* Encoding and decoding of time-related types are 10x faster (!!) as a
296 result of bypassing `Data.Time.Format` and the arbitrary-precision
299* When using `toEncoding`, `[Char]` can be encoded without a conversion to
300 `Text`. This is fast and efficient.
302* Parsing into an `Object` is now 5% faster and more
303 allocation-efficient.
305## SUBTLE API CHANGES, READ CAREFULLY
307With the exception of long-deprecated code, the API changes below
308**should be upwards compatible** from older versions of `aeson`. If you run
309into upgrade problems, please file an issue with details.
311* The `ToJSON` class has a new method, `toEncoding`, that allows
312 direct encoding from a Haskell value to a lazy bytestring without
313 construction of an intermediate `Value`.
315 The performance benefits of direct encoding are significant: more
316 than 2x faster than before, with less than 1/3 the memory usage.
318 To preserve API compatibility across upgrades from older versions of
319 this library, the default implementation of `toEncoding` uses
320 `toJSON`. You will *not* see any performance improvement unless you
321 write an implementation of `toEncoding`, which can be very simple:
324 instance ToJSON Coord where
325 toEncoding = genericToEncoding defaultOptions
328 (Behind the scenes, the `encode` function uses `toEncoding` now, so
329 if you implement `toEncoding` for your types, you should see a
330 speedup immediately.)
332 If you use Template Haskell or GHC Generics to auto-generate your
333 `ToJSON` instances, you'll benefit from fast toEncoding
334 implementations for free!
336* When converting from a `Value` to a target Haskell type, `FromJSON`
337 instances now provide much better error messages, including a
338 complete JSON path from the root of the object to the offending
339 element. This greatly eases debugging.
341* It is now possible to use Template Haskell to generate `FromJSON`
342 and `ToJSON` instances for types in data families.
344* If you use Template Haskell or generics, and used to use the
345 `camelTo` function to rename fields, the new `camelTo2` function is
346 smarter. For example, `camelTo` will rename `CamelAPICase` to
347 `camelapi_case` (ugh!), while `camelTo2` will map it to
348 `camel_api_case` (yay!).
350* New `ToJSON` and `FromJSON` instances for the following time-related
351 types: `Day`, `LocalTime`.
353* `FromJSON` `UTCTime` parser accepts the same values as for `ZonedTime`,
354 but converts any time zone offset into a UTC time.
356* The `Result` type is now an instance of `Foldable` and `Traversable`.
358* The `Data.Aeson.Generic` module has been removed. It was deprecated in
361* GHC 7.2 and older are no longer supported.
363* The instance of `Monad` for the `Result` type lacked an implementation
364 of `fail` (oops). This has been corrected.
366* Semantics of `(.:?)` operator are changed. It's doesn't anymore accept
367 present `Null` value.
369* Added `(Foldable t, ToJSON a) => ToJSON (t a)` overlappable instance.
370 You might see `No instance for (Foldable YourPolymorphicType) arising from a
371 use of ‘.=’` -errors due this change.
375* A stray export of `encodeToBuilder` got away!
379* The `json` and `json'` parsers are now synonyms for `value` and
380 `value'`, in conformance with the looser semantics of RFC 7159.
382* Renamed `encodeToByteStringBuilder` to the more compact
387* The dependency on the `unordered-containers` package was too lax,
388 and has been corrected.
392* Encoding a `Scientific` value with a huge exponent is now handled
393 efficiently. (This would previously allocate a huge
394 arbitrary-precision integer, potentially leading to a denial of
397* Handling of strings that contain backslash escape sequences is
398 greatly improved. For a pathological string containing almost a
399 megabyte of consecutive backslashes, the new implementation is 27x
400 faster and uses 42x less memory.
402* The `ToJSON` instance for `UTCTime` is rendered with higher
403 (picosecond) resolution.
405* The `value` parser now correctly handles leading whitespace.
407* New instances of `ToJSON` and `FromJSON` for `Data.Sequence` and
408 `Data.Functor.Identity`. The `Value` type now has a `Read` instance.
410* `ZonedTime` parser ordering now favours the standard `JSON` format,
411 increasing efficiency in the common case.
413* Encoding to a `Text.Builder` now escapes `'<'` and `'>'` characters,
418* Fix `ToJSON` instance for 15-tuples (see #223).
426* Add `ToJSON` and `FromJSON` instances for tuples of up to 15
431* Major compiler and library compatibility changes: we have dropped
432 support for GHC older than 7.4, `text` older than 1.1, and
433 `bytestring` older than 0.10.4.0. Supporting the older versions had
434 become increasingly difficult, to the point where it was no longer
439* The performance of encoding to and decoding of bytestrings have both
440 improved by up to 2x, while also using less memory.
442* New dependency: the `scientific` package lets us parse floating point
443 numbers more quickly and accurately.
445* `eitherDecode`, `decodeStrictWith`: fixed bugs.
447* Added `FromJSON` and `ToJSON` instances for `Tree` and `Scientific`.
449* Fixed the `ToJSON` instances for `UTCTime` and `ZonedTime`.
453* Much improved documentation.
455* Angle brackets are now escaped in JSON strings, to help avoid XSS
458* Fixed up handling of nullary constructors when using generic
461* Added `ToJSON`/`FromJSON` instances for:
464 * ISO-8601 dates: `UTCTime`, `ZonedTime`, and `TimeZone`
466* Added accessor functions for inspecting `Value`s.
468* Added `eitherDecode` function that returns an error message if
473* This release introduces a slightly obscure, but
474 backwards-incompatible, change.
476 In the generic APIs of versions 0.4 and 0.5, fields whose names
477 began with a `"_"` character would have this character removed. This
478 no longer occurs, as it was both buggy and surprising
479 (https://github.com/bos/aeson/issues/53).
481* Fixed a bug in generic decoding of nullary constructors
482 (https://github.com/bos/aeson/issues/62).
486* When used with the UTF-8 encoding performance improvements
487 introduced in version 0.11.1.12 of the `text` package, this release
488 improves `aeson`'s JSON encoding performance by 33% relative to
491 As part of achieving this improvement, an API change was necessary.
492 The `fromValue` function in the `Data.Aeson.Encode` module now uses
493 the `text` package's `Builder` type instead of the `blaze-builder`
494 package's `Builder` type.
498* The new `decode` function complements the longstanding `encode`
499 function, and makes the API simpler.
501* New examples make it easier to learn to use the package
502 (https://github.com/bos/aeson/tree/master/examples).
506 `aeson`'s support for data-type generic programming makes it
507 possible to use JSON encodings of most data types without writing
508 any boilerplate instances.
510 Thanks to Bas Van Dijk, `aeson` now supports the two major schemes
511 for doing datatype-generic programming:
513 * the modern mechanism, built into GHC itself
514 (http://www.haskell.org/ghc/docs/latest/html/users_guide/generic-programming.html)
516 * the older mechanism, based on SYB (aka "scrap your
519 The modern GHC-based generic mechanism is fast and terse: in fact,
520 its performance is generally comparable in performance to
521 hand-written and TH-derived `ToJSON` and `FromJSON` instances. To
522 see how to use GHC generics, refer to `examples/Generic.hs`.
524 The SYB-based generics support lives in `Data.Aeson.Generic` and is
525 provided mainly for users of GHC older than 7.2. SYB is far slower
526 (by about 10x) than the more modern generic mechanism. To see how
527 to use SYB generics, refer to `examples/GenericSYB.hs`.
529* We switched the intermediate representation of JSON objects from
530 `Data.Map` to `Data.HashMap` which has improved type conversion
533* Instances of `ToJSON` and `FromJSON` for tuples are between 45% and 70%
538 This version of aeson makes explicit the decoupling between
539 *identifying* an element of a JSON document and *converting* it to
540 Haskell. See the `Data.Aeson.Parser` documentation for details.
542 The normal `aeson` `decode` function performs identification
543 strictly, but defers conversion until needed. This can result in
544 improved performance (e.g. if the results of some conversions are
545 never needed), but at a cost in increased memory consumption.
547 The new `decode'` function performs identification and conversion
548 immediately. This incurs an up-front cost in CPU cycles, but
549 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