on v1420 help sign in
typeable/aeson/changelog.md
620 lines 23 kB history raw
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).
3### 1.4.2.0
5* Add `Data.Aeson.QQ.Simple` which is a simpler version of the `aeson-qq` package, it does not support interpolation, thanks to Oleg Grenrus.
6* Add `Contravariant ToJSONKeyFunction` instance, thanks to Oleg Grenrus.
7* Add `KeyValue Object` instance, thanks to Robert Hensing
8* Improved performance when parsing large numbers, thanks to Oleg Grenrus.
10### 1.4.1.0
12* Optimizations of generics, thanks to Rémy Oudompheng, here are some numbers for GHC 8.4:
13 * Compilation time: G/BigProduct.hs is 25% faster, G/BigRecord.hs is 2x faster.
14 * Runtime performance: BigRecord/toJSON/generic and BigProduct/encode/generic are more than 2x faster.
15* Added To/FromJSON instances for `Void` and Generics's `V1`, thanks to Will Yager
16* Added To/FromJSON instances for `primitive`'s `Array`, `SmallArray`, `PrimArray` and `UnliftedArray`, thanks to Andrew Thad.
17* Fixes handling of `UTCTime` wrt. leap seconds , thanks to Adam Schønemann
18* Warning and documentation fixes thanks to tom-bop, Gabor Greif, Ian Jeffries, and Mateusz Curyło.
20## 1.4.0.0
22This release introduces bounds on the size of `Scientific` numbers when they are converted to other arbitrary precision types that do not represent them efficiently in memory.
24This means that trying to decode a number such as `1e1000000000` into an `Integer` will now fail instead of using a lot of memory. If you need to represent large numbers you can add a newtype (preferably over `Scientific`) and providing a parser using `withScientific`.
26The following instances are affected by this:
27* `FromJSON Natural`
28* `FromJSONKey Natural`
29* `FromJSON Integer`
30* `FromJSONKey Integer`
31* `FromJSON NominalDiffTime`
33For the same reasons the following instances & functions have been removed:
34* Remove `FromJSON Data.Attoparsec.Number` instance. Note that `Data.Attoparsec.Number` is deprecated.
35* Remove deprecated `withNumber`, use `withScientific` instead.
37Finally, encoding integral values with large exponents now uses scientific notation, this saves space for large numbers.
39#### 1.3.1.1
41* Catch 0 denominators when parsing Ratio
43### 1.3.1.0
45* Fix bug in generically derived `FromJSON` instances that are using `unwrapUnaryRecords`, thanks to Xia Li-yao
46* Allow base-compat 0.10.*, thanks to Oleg Grenrus
48## 1.3.0.0
50Breaking changes:
51* `GKeyValue` has been renamed to `KeyValuePair`, thanks to Xia Li-yao
52* Removed unused `FromJSON` constraint in `withEmbeddedJson`, thanks to Tristan Seligmann
54Other improvements:
55* Optimizations of TH toEncoding, thanks to Xia Li-yao
56* Optimizations of hex decoding when using the default/pure unescape implementation, thanks to Xia Li-yao
57* Improved error message on `Day` parse failures, thanks to Gershom Bazerman
58* Add `encodeFile` as well as `decodeFile*` variants, thanks to Markus Hauck
59* Documentation fixes, thanks to Lennart Spitzner
60* CPP cleanup, thanks to Ryan Scott
62### 1.2.4.0
64* Add `Ord` instance for `JSONPathElement`, thanks to Simon Hengel.
67### 1.2.3.0
69* Added `withEmbeddedJSON` to help parse JSON embedded inside a JSON string, thanks to Jesse Kempf.
70* Memory usage improvements to the default (pure) parser, thanks to Jonathan Paugh. Also thanks to Neil Mitchell & Oleg Grenrus for contributing a benchmark.
71* `omitNothingFields` now works for the `Option` newtype, thanks to Xia Li-yao.
72* Some documentation fixes, thanks to Jonathan Paug & Philippe Crama.
74### 1.2.2.0
76* Add `FromJSON` and `ToJSON` instances for
77 * `DiffTime`, thanks to Víctor López Juan.
78 * `CTime`, thanks to Daniel Díaz.
79* Fix handling of fractions when parsing Natural, thanks to Yuriy Syrovetskiy.
80* Change text in error messages for Integral types to make them follow the common pattern, thanks to Yuriy Syrovetskiy.
81* Add missing `INCOHERENT` pragma for `RecordToPair`, thanks to Xia Li-yao.
82* Everything related to `Options` is now exported from `Data.Aeson`, thanks to Xia Li-yao.
83* Optimizations to not escape text in clear cases, thanks to Oleg Grenrus.
84* Some documentation fixes, thanks to Phil de Joux & Xia Li-yao.
86### 1.2.1.0
88* Add `parserThrowError` and `parserCatchError` combinators, thanks to Oleg Grenrus.
90* Add `Generic` instance for `Value`, thanks to Xia Li-yao.
92* Fix a mistake in the 1.2.0.0 changelog, the `cffi` flag is disabled by default! Thanks to dbaynard.
94## 1.2.0.0
96* `tagSingleConstructors`, an option to encode single-constructor types as tagged sums was added to `Options`. It is disabled by default for backward compatibility.
98* 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.
100* The `Options` constructor is no longer exposed to prevent new options from being breaking changes, use `defaultOptions` instead.
102* The contents of `GToJSON` and `GToEncoding` are no longer exposed.
104* Some INLINE pragmas were removed to avoid GHC running out of simplifier ticks.
106### 1.1.2.0
108* Fix an accidental change in the format of `deriveJSON`. Thanks to Xia Li-yao!
110* Documentation improvements regarding `ToJSON`, `FromJSON`, and `SumEncoding`. Thanks to Xia Li-yao and Lennart Spitzner!
112### 1.1.1.0
114* 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!
116* 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!
118## 1.1.0.0
120* Added instances for `UUID`.
122* The operators for parsing fields now have named aliases:
123 - `.:` => `parseField`
124 - `.:?` => `parseFieldMaybe`
125 - `.:!` => `parseFieldMaybe'`
126 - These functions now also have variants with explicit parser functions: `explicitParseField`, `explicitParseFieldMaybe`, "explicitParseFieldMaybe'`
127Thanks to Oleg Grenrus.
129* `ToJSONKey (Identity a)` and `FromJSONKey (Identity a)` no longer require the unnecessary `FromJSON a` constraint. Thanks to Oleg Grenrus.
131* Added `Data.Aeson.Encoding.pair'` which is a more general version of `Data.Aeson.Encoding.pair`. Thanks to Andrew Martin.
133* `Day`s BCE are properly encoded and `+` is now a valid prefix for `Day`s CE. Thanks to Matt Parsons.
135* Some commonly used ToJSON instances are now specialized in order to improve compile time. Thanks to Bartosz Nitka.
138[JSONTestSuite](https://github.com/nst/JSONTestSuite) cleanups, all
139motivated by tighter RFC 7159 compliance:
141* The parser now rejects numbers for which
142 [the integer portion contains a leading zero](https://github.com/bos/aeson/commit/3fb7c155f2255482b1b9566ec5c1eaf9895d630e).
143* The parser now rejects numbers for which
144 [a decimal point is not followed by at least one digit](https://github.com/bos/aeson/commit/ecfca35a45286dbe2bbaf5f62354be393bc59b66),
145* The parser now rejects documents that contain [whitespace outside the
146 set {space, newline, carriage return, tab}](https://github.com/bos/aeson/commit/8ef622c2ad8d4a109884e17c2792238a2a320e44).
148Over 90% of JSONTestSuite tests currently pass. The remainder can be
149categorised as follows:
151* The string parser is strict with Unicode compliance where the RFC
152 leaves room for implementation-defined behaviour (tests prefixed
153 with "`i_string_`". (This is necessary because the `text` library
154 cannot accommodate invalid Unicode.)
156* The parser does not (and will not) support UTF-16, UTF-32, or byte
157 order marks (BOM).
158* The parser accepts unescaped control characters, even though the RFC
159 states that control characters must be escaped. (This may change at
160 some point, but doesn't seem important.)
162#### 1.0.2.1
164* Fixes a regression where a bunch of valid characters caused an
165 "Invalid UTF8-Stream" error when decoding. Thanks to Vladimir
166 Shabanov who investigated and fixed this.
168### 1.0.2.0
170* Fixes a regression where it was no longer possible to derive
171 instances for types such as `data T a = T { f1 :: a, f2 :: Maybe a
172 }`.
174Thanks to Sean Leather for fixing this, and to Ryan Scott for helping out.
176### 1.0.1.0
178* Decoding performance has been significantly improved (see
179 https://github.com/bos/aeson/pull/452). Thanks to @winterland1989.
181* Add `ToJSON`/`FromJSON` instances for newtypes from
182 `Data.Semigroup`: `Min`, `Max`, `First`, `Last`, `WrappedMonoid`,
183 `Option`. Thanks to Lennart Spitzner.
185* Make the documentation for `.:!` more accurate. Thanks to Ian Jeffries.
187# 1.0.0.0
189Major enhancements:
191* Introduced new `FromJSONKey` and `ToJSONKey` type classes that are
192 used to encode maps without going through HashMap. This also allows arbitrary
193 serialization of keys where a string-like key will encode into an object and
194 other keys will encode into an array of key-value tuples.
196* Added higher rank classes: `ToJSON1`, `ToJSON2`, `FromJSON1`, and
197 `FromJSON2`.
199* Added `Data.Aeson.Encoding` with functions to safely write `ToJSON`
200 instances using `toEncoding`.
202Other enhancements:
204* 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:
205```
206flags:
207 aeson:
208 fast: true
209```
211* Added list specific members to `ToJSON` and `FromJSON` classes. In
212 the same way `Read` and `Show` handle lists specifically. This
213 removes need for overlapping instances to handle `String`.
215* Added a new `sumEncoding` option `UntaggedValue` which prevents
216 objects from being tagged with the constructor name.
218* JSONPaths are now tracked in instances derived with template-haskell
219 and generics.
221* Get rid of redundancy of JSONPath error messages in nested records.
223 `eitherDecode "{\"x\":{\"a\": [1,2,true]}}" :: Either String Y`
224 previously yielded
225 `Error in $.x.a[2]: failed to parse field" x: failed to parse field a: expected Int, encountered Boolean`
226 and now yields `Error in $.x.a[2]: expected Int, encountered Boolean"`.
228 Some users might prefer to insert `modifyFailure` themselves to
229 customize error messages, which previously prevented the use of
230 `(.:)`.
232* Backwards compatibility with `bytestring-0.9` using the
233 `bytestring-builder` compatibility package.
235* Export `decodeWith`, `decodeStrictWith`, `eitherDecodeWith`, and
236 `eitherDecodeStrictWith` from `Data.Aeson.Parser`. This allows
237 decoding using explicit parsers instead of using `FromJSON`
238 instances.
240* Un-orphan internal instances to render them in haddocks.
242Other changes:
244* Integral `FromJSON` instances now only accept integral
245 values. E.g. parsing `3.14` to `Int` fails instead of succeeding
246 with the value `3`.
248* Over/underflows are now caught for bounded numeric types.
250* Remove the `contents` field encoding with `allNullaryToStringTag = False`,
251 giving us `{ "tag" : "c1" }` instead of `{ "tag" : "c1", contents : [] }`.
252 The contents field is optional when parsing so this is only a breaking
253 change for ToJSON instances.
255* Fix a bug where `genericToEncoding` with `unwrapUnaryRecords = True`
256 would produce an invalid encoding: `"unwrap\":""`.
258* `ToJSON` instances using `genericToEncoding` and `omitNothingFields`
259 no longer produce invalid JSON.
261* Added instances for `DList`, `Compose`, `Product`, `Sum`.
263### 0.11.2.0
265* Enable `PolyKinds` to generalize `Proxy`, `Tagged`, and `Const` instances.
266* Add `unsafeToEncoding` in `Data.Aeson.Types`, use with care!
268#### 0.11.1.4
270* Fix build with `base >= 4.8` and `unordered-containers < 0.2.6`.
272#### 0.11.1.3
274* Fix build on TH-less GHCs
276#### 0.11.1.2
278* Fix build with `base < 4.8` and `unordered-containers < 0.2.6`.
279* Add missing field in docs for `defaultOptions`.
281#### 0.11.1.1
283* Fixes a bug where the hashes of equal values could differ.
285### 0.11.1.0
287The only changes are added instances.
289These are new:
290* `ToJSON a => ToJSON (NonEmpty a)`
291* `FromJSON a => FromJSON (NonEmpty a)`
292* `ToJSON (Proxy a)`
293* `FromJSON (Proxy a)`
294* `ToJSON b => ToJSON (Tagged a b)`
295* `FromJSON b => FromJSON (Tagged a b)`
296* `ToJSON a => ToJSON (Const a b)`
297* `FromJSON a => FromJSON (Const a b)`
299These are now available for older GHCs:
300* `ToJSON Natural`
301* `FromJSON Natural`
303# 0.11.0.0
305This release should be close to backwards compatible with aeson 0.9.
307If you are upgrading from aeson 0.10 it might be easier to go back in
308history to the point you were still using 0.9.
310**Breaking changes**:
312* Revert `.:?` to behave like it did in 0.9. If you want the 0.10
313 behavior use `.:!` instead.
315* Revert JSON format of `Either` to 0.9, `Left` and `Right` are now
316 serialized with an initial uppercase letter. If you want the names
317 in lowercase you can add a newtype with an instance.
319* All `ToJSON` and `FromJSON` instances except for `[a]` are no longer
320 `OVERLAPPABLE`. Mark your instance as `OVERLAPPING` if it overlaps
321 any of the other aeson instances.
323* All `ToJSON` and `FromJSON` instances except for `[Char]` are no
324 longer incoherent, this means you may need to replace your
325 incoherent instances with a newtyped instance.
327**Additions**:
329* Introduce `.:!` that behaves like `.:?` did in 0.10.
331* Allow `HH:MM` format for `ZonedTime` and `UTCTime`.
332 This is one of the formats allowed by
333 [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#Times).
335* Added `ToJSON` and `FromJSON` instances for the
336 `Version`, `Ordering`, and `Natural` types.
338**Bug fixes**:
340* JSONPath identifiers are now escaped if they contain invalid characters.
342* Fixed JSONPath messages for Seq to include indices.
344* Fixed JSONPath messages for Either to include `left`/`right`.
346* Fix missing quotes surrounding time encodings.
348* Fix #293: Type error in TH when using `omitNothingFields = True`.
350**Compatibility**:
352* Various updates to support GHC 8.
355# 0.10.0.0
357## Performance improvements
359* Direct encoding via the new `toEncoding` method is over 2x faster
360 than `toJSON`. (You must write or code-gen a `toEncoding`
361 implementation to unlock this speedup. See below for details.)
363* Improved string decoding gives a 12% speed win in parsing
364 string-heavy JSON payloads (very common).
366* Encoding and decoding of time-related types are 10x faster (!!) as a
367 result of bypassing `Data.Time.Format` and the arbitrary-precision
368 `Integer` type.
370* When using `toEncoding`, `[Char]` can be encoded without a conversion to
371 `Text`. This is fast and efficient.
373* Parsing into an `Object` is now 5% faster and more
374 allocation-efficient.
376## SUBTLE API CHANGES, READ CAREFULLY
378With the exception of long-deprecated code, the API changes below
379**should be upwards compatible** from older versions of `aeson`. If you run
380into upgrade problems, please file an issue with details.
382* The `ToJSON` class has a new method, `toEncoding`, that allows
383 direct encoding from a Haskell value to a lazy bytestring without
384 construction of an intermediate `Value`.
386 The performance benefits of direct encoding are significant: more
387 than 2x faster than before, with less than 1/3 the memory usage.
389 To preserve API compatibility across upgrades from older versions of
390 this library, the default implementation of `toEncoding` uses
391 `toJSON`. You will *not* see any performance improvement unless you
392 write an implementation of `toEncoding`, which can be very simple:
394 ```haskell
395 instance ToJSON Coord where
396 toEncoding = genericToEncoding defaultOptions
397 ```
399 (Behind the scenes, the `encode` function uses `toEncoding` now, so
400 if you implement `toEncoding` for your types, you should see a
401 speedup immediately.)
403 If you use Template Haskell or GHC Generics to auto-generate your
404 `ToJSON` instances, you'll benefit from fast toEncoding
405 implementations for free!
407* When converting from a `Value` to a target Haskell type, `FromJSON`
408 instances now provide much better error messages, including a
409 complete JSON path from the root of the object to the offending
410 element. This greatly eases debugging.
412* It is now possible to use Template Haskell to generate `FromJSON`
413 and `ToJSON` instances for types in data families.
415* If you use Template Haskell or generics, and used to use the
416 `camelTo` function to rename fields, the new `camelTo2` function is
417 smarter. For example, `camelTo` will rename `CamelAPICase` to
418 `camelapi_case` (ugh!), while `camelTo2` will map it to
419 `camel_api_case` (yay!).
421* New `ToJSON` and `FromJSON` instances for the following time-related
422 types: `Day`, `LocalTime`.
424* `FromJSON` `UTCTime` parser accepts the same values as for `ZonedTime`,
425 but converts any time zone offset into a UTC time.
427* The `Result` type is now an instance of `Foldable` and `Traversable`.
429* The `Data.Aeson.Generic` module has been removed. It was deprecated in
430 late 2013.
432* GHC 7.2 and older are no longer supported.
434* The instance of `Monad` for the `Result` type lacked an implementation
435 of `fail` (oops). This has been corrected.
437* Semantics of `(.:?)` operator are changed. It's doesn't anymore accept
438 present `Null` value.
440* Added `(Foldable t, ToJSON a) => ToJSON (t a)` overlappable instance.
441 You might see `No instance for (Foldable YourPolymorphicType) arising from a
442 use of ‘.=’` -errors due this change.
444# 0.9.0.1
446* A stray export of `encodeToBuilder` got away!
448# 0.9.0.0
450* The `json` and `json'` parsers are now synonyms for `value` and
451 `value'`, in conformance with the looser semantics of RFC 7159.
453* Renamed `encodeToByteStringBuilder` to the more compact
454 `encodeToBuilder`.
456# 0.8.1.1
458* The dependency on the `unordered-containers` package was too lax,
459 and has been corrected.
461# 0.8.1.0
463* Encoding a `Scientific` value with a huge exponent is now handled
464 efficiently. (This would previously allocate a huge
465 arbitrary-precision integer, potentially leading to a denial of
466 service.)
468* Handling of strings that contain backslash escape sequences is
469 greatly improved. For a pathological string containing almost a
470 megabyte of consecutive backslashes, the new implementation is 27x
471 faster and uses 42x less memory.
473* The `ToJSON` instance for `UTCTime` is rendered with higher
474 (picosecond) resolution.
476* The `value` parser now correctly handles leading whitespace.
478* New instances of `ToJSON` and `FromJSON` for `Data.Sequence` and
479 `Data.Functor.Identity`. The `Value` type now has a `Read` instance.
481* `ZonedTime` parser ordering now favours the standard `JSON` format,
482 increasing efficiency in the common case.
484* Encoding to a `Text.Builder` now escapes `'<'` and `'>'` characters,
485 to reduce XSS risk.
487# 0.8.0.2
489* Fix `ToJSON` instance for 15-tuples (see #223).
491# 0.8.0.1
493* Support `time-1.5`.
495# 0.8.0.0
497* Add `ToJSON` and `FromJSON` instances for tuples of up to 15
498 elements.
500# 0.7.1.0
502* Major compiler and library compatibility changes: we have dropped
503 support for GHC older than 7.4, `text` older than 1.1, and
504 `bytestring` older than 0.10.4.0. Supporting the older versions had
505 become increasingly difficult, to the point where it was no longer
506 worth it.
508# 0.7.0.0
510* The performance of encoding to and decoding of bytestrings have both
511 improved by up to 2x, while also using less memory.
513* New dependency: the `scientific` package lets us parse floating point
514 numbers more quickly and accurately.
516* `eitherDecode`, `decodeStrictWith`: fixed bugs.
518* Added `FromJSON` and `ToJSON` instances for `Tree` and `Scientific`.
520* Fixed the `ToJSON` instances for `UTCTime` and `ZonedTime`.
522# 0.6 series
524* Much improved documentation.
526* Angle brackets are now escaped in JSON strings, to help avoid XSS
527 attacks.
529* Fixed up handling of nullary constructors when using generic
530 encoding.
532* Added `ToJSON`/`FromJSON` instances for:
534 * The `Fixed` class
535 * ISO-8601 dates: `UTCTime`, `ZonedTime`, and `TimeZone`
537* Added accessor functions for inspecting `Value`s.
539* Added `eitherDecode` function that returns an error message if
540 decoding fails.
542# 0.5 to 0.6
544* This release introduces a slightly obscure, but
545 backwards-incompatible, change.
547 In the generic APIs of versions 0.4 and 0.5, fields whose names
548 began with a `"_"` character would have this character removed. This
549 no longer occurs, as it was both buggy and surprising
550 (https://github.com/bos/aeson/issues/53).
552* Fixed a bug in generic decoding of nullary constructors
553 (https://github.com/bos/aeson/issues/62).
555# 0.4 to 0.5
557* When used with the UTF-8 encoding performance improvements
558 introduced in version 0.11.1.12 of the `text` package, this release
559 improves `aeson`'s JSON encoding performance by 33% relative to
560 `aeson` 0.4.
562 As part of achieving this improvement, an API change was necessary.
563 The `fromValue` function in the `Data.Aeson.Encode` module now uses
564 the `text` package's `Builder` type instead of the `blaze-builder`
565 package's `Builder` type.
567# 0.3 to 0.4
569* The new `decode` function complements the longstanding `encode`
570 function, and makes the API simpler.
572* New examples make it easier to learn to use the package
573 (https://github.com/bos/aeson/tree/master/examples).
575* Generics support
577 `aeson`'s support for data-type generic programming makes it
578 possible to use JSON encodings of most data types without writing
579 any boilerplate instances.
581 Thanks to Bas Van Dijk, `aeson` now supports the two major schemes
582 for doing datatype-generic programming:
584 * the modern mechanism, built into GHC itself
585 (http://www.haskell.org/ghc/docs/latest/html/users_guide/generic-programming.html)
587 * the older mechanism, based on SYB (aka "scrap your
588 boilerplate")
590 The modern GHC-based generic mechanism is fast and terse: in fact,
591 its performance is generally comparable in performance to
592 hand-written and TH-derived `ToJSON` and `FromJSON` instances. To
593 see how to use GHC generics, refer to `examples/Generic.hs`.
595 The SYB-based generics support lives in `Data.Aeson.Generic` and is
596 provided mainly for users of GHC older than 7.2. SYB is far slower
597 (by about 10x) than the more modern generic mechanism. To see how
598 to use SYB generics, refer to `examples/GenericSYB.hs`.
600* We switched the intermediate representation of JSON objects from
601 `Data.Map` to `Data.HashMap` which has improved type conversion
602 performance.
604* Instances of `ToJSON` and `FromJSON` for tuples are between 45% and 70%
605 faster than in 0.3.
607* Evaluation control
609 This version of aeson makes explicit the decoupling between
610 *identifying* an element of a JSON document and *converting* it to
611 Haskell. See the `Data.Aeson.Parser` documentation for details.
613 The normal `aeson` `decode` function performs identification
614 strictly, but defers conversion until needed. This can result in
615 improved performance (e.g. if the results of some conversions are
616 never needed), but at a cost in increased memory consumption.
618 The new `decode'` function performs identification and conversion
619 immediately. This incurs an up-front cost in CPU cycles, but
620 reduces reduce memory consumption.