on 1.2.1.0 help sign in
typeable/aeson/changelog.md
537 lines 19 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.2.1.0
5* Add `parserThrowError` and `parserCatchError` combinators, thanks to Oleg Grenrus.
7* Add `Generic` instance for `Value`, thanks to Xia Li-yao.
9* Fix a mistake in the 1.2.0.0 changelog, the `cffi` flag is disabled by default! Thanks to dbaynard.
11## 1.2.0.0
13* `tagSingleConstructors`, an option to encode single-constructor types as tagged sums was added to `Options`. It is disabled by default for backward compatibility.
15* 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.
17* The `Options` constructor is no longer exposed to prevent new options from being breaking changes, use `defaultOptions` instead.
19* The contents of `GToJSON` and `GToEncoding` are no longer exposed.
21* Some INLINE pragmas were removed to avoid GHC running out of simplifier ticks.
23### 1.1.2.0
25* Fix an accidental change in the format of `deriveJSON`. Thanks to Xia Li-yao!
27* Documentation improvements regarding `ToJSON`, `FromJSON`, and `SumEncoding`. Thanks to Xia Li-yao and Lennart Spitzner!
29### 1.1.1.0
31* 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!
33* 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!
35## 1.1.0.0
37* Added instances for `UUID`.
39* The operators for parsing fields now have named aliases:
40 - `.:` => `parseField`
41 - `.:?` => `parseFieldMaybe`
42 - `.:!` => `parseFieldMaybe'`
43 - These functions now also have variants with explicit parser functions: `explicitParseField`, `explicitParseFieldMaybe`, "explicitParseFieldMaybe'`
44Thanks to Oleg Grenrus.
46* `ToJSONKey (Identity a)` and `FromJSONKey (Identity a)` no longer require the unnecessary `FromJSON a` constraint. Thanks to Oleg Grenrus.
48* Added `Data.Aeson.Encoding.pair'` which is a more general version of `Data.Aeson.Encoding.pair`. Thanks to Andrew Martin.
50* `Day`s BCE are properly encoded and `+` is now a valid prefix for `Day`s CE. Thanks to Matt Parsons.
52* Some commonly used ToJSON instances are now specialized in order to improve compile time. Thanks to Bartosz Nitka.
55[JSONTestSuite](https://github.com/nst/JSONTestSuite) cleanups, all
56motivated by tighter RFC 7159 compliance:
58* The parser now rejects numbers for which
59 [the integer portion contains a leading zero](https://github.com/bos/aeson/commit/3fb7c155f2255482b1b9566ec5c1eaf9895d630e).
60* The parser now rejects numbers for which
61 [a decimal point is not followed by at least one digit](https://github.com/bos/aeson/commit/ecfca35a45286dbe2bbaf5f62354be393bc59b66),
62* The parser now rejects documents that contain [whitespace outside the
63 set {space, newline, carriage return, tab}](https://github.com/bos/aeson/commit/8ef622c2ad8d4a109884e17c2792238a2a320e44).
65Over 90% of JSONTestSuite tests currently pass. The remainder can be
66categorised as follows:
68* The string parser is strict with Unicode compliance where the RFC
69 leaves room for implementation-defined behaviour (tests prefixed
70 with "`i_string_`". (This is necessary because the `text` library
71 cannot accommodate invalid Unicode.)
73* The parser does not (and will not) support UTF-16, UTF-32, or byte
74 order marks (BOM).
75* The parser accepts unescaped control characters, even though the RFC
76 states that control characters must be escaped. (This may change at
77 some point, but doesn't seem important.)
79#### 1.0.2.1
81* Fixes a regression where a bunch of valid characters caused an
82 "Invalid UTF8-Stream" error when decoding. Thanks to Vladimir
83 Shabanov who investigated and fixed this.
85### 1.0.2.0
87* Fixes a regression where it was no longer possible to derive
88 instances for types such as `data T a = T { f1 :: a, f2 :: Maybe a
89 }`.
91Thanks to Sean Leather for fixing this, and to Ryan Scott for helping out.
93### 1.0.1.0
95* Decoding performance has been significantly improved (see
96 https://github.com/bos/aeson/pull/452). Thanks to @winterland1989.
98* Add `ToJSON`/`FromJSON` instances for newtypes from
99 `Data.Semigroup`: `Min`, `Max`, `First`, `Last`, `WrappedMonoid`,
100 `Option`. Thanks to Lennart Spitzner.
102* Make the documentation for `.:!` more accurate. Thanks to Ian Jeffries.
104# 1.0.0.0
106Major enhancements:
108* Introduced new `FromJSONKey` and `ToJSONKey` type classes that are
109 used to encode maps without going through HashMap. This also allows arbitrary
110 serialization of keys where a string-like key will encode into an object and
111 other keys will encode into an array of key-value tuples.
113* Added higher rank classes: `ToJSON1`, `ToJSON2`, `FromJSON1`, and
114 `FromJSON2`.
116* Added `Data.Aeson.Encoding` with functions to safely write `ToJSON`
117 instances using `toEncoding`.
119Other enhancements:
121* 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:
122```
123flags:
124 aeson:
125 fast: true
126```
128* Added list specific members to `ToJSON` and `FromJSON` classes. In
129 the same way `Read` and `Show` handle lists specifically. This
130 removes need for overlapping instances to handle `String`.
132* Added a new `sumEncoding` option `UntaggedValue` which prevents
133 objects from being tagged with the constructor name.
135* JSONPaths are now tracked in instances derived with template-haskell
136 and generics.
138* Get rid of redundancy of JSONPath error messages in nested records.
140 `eitherDecode "{\"x\":{\"a\": [1,2,true]}}" :: Either String Y`
141 previously yielded
142 `Error in $.x.a[2]: failed to parse field" x: failed to parse field a: expected Int, encountered Boolean`
143 and now yields `Error in $.x.a[2]: expected Int, encountered Boolean"`.
145 Some users might prefer to insert `modifyFailure` themselves to
146 customize error messages, which previously prevented the use of
147 `(.:)`.
149* Backwards compatibility with `bytestring-0.9` using the
150 `bytestring-builder` compatibility package.
152* Export `decodeWith`, `decodeStrictWith`, `eitherDecodeWith`, and
153 `eitherDecodeStrictWith` from `Data.Aeson.Parser`. This allows
154 decoding using explicit parsers instead of using `FromJSON`
155 instances.
157* Un-orphan internal instances to render them in haddocks.
159Other changes:
161* Integral `FromJSON` instances now only accept integral
162 values. E.g. parsing `3.14` to `Int` fails instead of succeeding
163 with the value `3`.
165* Over/underflows are now caught for bounded numeric types.
167* Remove the `contents` field encoding with `allNullaryToStringTag = False`,
168 giving us `{ "tag" : "c1" }` instead of `{ "tag" : "c1", contents : [] }`.
169 The contents field is optional when parsing so this is only a breaking
170 change for ToJSON instances.
172* Fix a bug where `genericToEncoding` with `unwrapUnaryRecords = True`
173 would produce an invalid encoding: `"unwrap\":""`.
175* `ToJSON` instances using `genericToEncoding` and `omitNothingFields`
176 no longer produce invalid JSON.
178* Added instances for `DList`, `Compose`, `Product`, `Sum`.
180### 0.11.2.0
182* Enable `PolyKinds` to generalize `Proxy`, `Tagged`, and `Const` instances.
183* Add `unsafeToEncoding` in `Data.Aeson.Types`, use with care!
185#### 0.11.1.4
187* Fix build with `base >= 4.8` and `unordered-containers < 0.2.6`.
189#### 0.11.1.3
191* Fix build on TH-less GHCs
193#### 0.11.1.2
195* Fix build with `base < 4.8` and `unordered-containers < 0.2.6`.
196* Add missing field in docs for `defaultOptions`.
198#### 0.11.1.1
200* Fixes a bug where the hashes of equal values could differ.
202### 0.11.1.0
204The only changes are added instances.
206These are new:
207* `ToJSON a => ToJSON (NonEmpty a)`
208* `FromJSON a => FromJSON (NonEmpty a)`
209* `ToJSON (Proxy a)`
210* `FromJSON (Proxy a)`
211* `ToJSON b => ToJSON (Tagged a b)`
212* `FromJSON b => FromJSON (Tagged a b)`
213* `ToJSON a => ToJSON (Const a b)`
214* `FromJSON a => FromJSON (Const a b)`
216These are now available for older GHCs:
217* `ToJSON Natural`
218* `FromJSON Natural`
220# 0.11.0.0
222This release should be close to backwards compatible with aeson 0.9.
224If you are upgrading from aeson 0.10 it might be easier to go back in
225history to the point you were still using 0.9.
227**Breaking changes**:
229* Revert `.:?` to behave like it did in 0.9. If you want the 0.10
230 behavior use `.:!` instead.
232* Revert JSON format of `Either` to 0.9, `Left` and `Right` are now
233 serialized with an initial uppercase letter. If you want the names
234 in lowercase you can add a newtype with an instance.
236* All `ToJSON` and `FromJSON` instances except for `[a]` are no longer
237 `OVERLAPPABLE`. Mark your instance as `OVERLAPPING` if it overlaps
238 any of the other aeson instances.
240* All `ToJSON` and `FromJSON` instances except for `[Char]` are no
241 longer incoherent, this means you may need to replace your
242 incoherent instances with a newtyped instance.
244**Additions**:
246* Introduce `.:!` that behaves like `.:?` did in 0.10.
248* Allow `HH:MM` format for `ZonedTime` and `UTCTime`.
249 This is one of the formats allowed by
250 [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#Times).
252* Added `ToJSON` and `FromJSON` instances for the
253 `Version`, `Ordering`, and `Natural` types.
255**Bug fixes**:
257* JSONPath identifiers are now escaped if they contain invalid characters.
259* Fixed JSONPath messages for Seq to include indices.
261* Fixed JSONPath messages for Either to include `left`/`right`.
263* Fix missing quotes surrounding time encodings.
265* Fix #293: Type error in TH when using `omitNothingFields = True`.
267**Compatibility**:
269* Various updates to support GHC 8.
272# 0.10.0.0
274## Performance improvements
276* Direct encoding via the new `toEncoding` method is over 2x faster
277 than `toJSON`. (You must write or code-gen a `toEncoding`
278 implementation to unlock this speedup. See below for details.)
280* Improved string decoding gives a 12% speed win in parsing
281 string-heavy JSON payloads (very common).
283* Encoding and decoding of time-related types are 10x faster (!!) as a
284 result of bypassing `Data.Time.Format` and the arbitrary-precision
285 `Integer` type.
287* When using `toEncoding`, `[Char]` can be encoded without a conversion to
288 `Text`. This is fast and efficient.
290* Parsing into an `Object` is now 5% faster and more
291 allocation-efficient.
293## SUBTLE API CHANGES, READ CAREFULLY
295With the exception of long-deprecated code, the API changes below
296**should be upwards compatible** from older versions of `aeson`. If you run
297into upgrade problems, please file an issue with details.
299* The `ToJSON` class has a new method, `toEncoding`, that allows
300 direct encoding from a Haskell value to a lazy bytestring without
301 construction of an intermediate `Value`.
303 The performance benefits of direct encoding are significant: more
304 than 2x faster than before, with less than 1/3 the memory usage.
306 To preserve API compatibility across upgrades from older versions of
307 this library, the default implementation of `toEncoding` uses
308 `toJSON`. You will *not* see any performance improvement unless you
309 write an implementation of `toEncoding`, which can be very simple:
311 ```haskell
312 instance ToJSON Coord where
313 toEncoding = genericToEncoding defaultOptions
314 ```
316 (Behind the scenes, the `encode` function uses `toEncoding` now, so
317 if you implement `toEncoding` for your types, you should see a
318 speedup immediately.)
320 If you use Template Haskell or GHC Generics to auto-generate your
321 `ToJSON` instances, you'll benefit from fast toEncoding
322 implementations for free!
324* When converting from a `Value` to a target Haskell type, `FromJSON`
325 instances now provide much better error messages, including a
326 complete JSON path from the root of the object to the offending
327 element. This greatly eases debugging.
329* It is now possible to use Template Haskell to generate `FromJSON`
330 and `ToJSON` instances for types in data families.
332* If you use Template Haskell or generics, and used to use the
333 `camelTo` function to rename fields, the new `camelTo2` function is
334 smarter. For example, `camelTo` will rename `CamelAPICase` to
335 `camelapi_case` (ugh!), while `camelTo2` will map it to
336 `camel_api_case` (yay!).
338* New `ToJSON` and `FromJSON` instances for the following time-related
339 types: `Day`, `LocalTime`.
341* `FromJSON` `UTCTime` parser accepts the same values as for `ZonedTime`,
342 but converts any time zone offset into a UTC time.
344* The `Result` type is now an instance of `Foldable` and `Traversable`.
346* The `Data.Aeson.Generic` module has been removed. It was deprecated in
347 late 2013.
349* GHC 7.2 and older are no longer supported.
351* The instance of `Monad` for the `Result` type lacked an implementation
352 of `fail` (oops). This has been corrected.
354* Semantics of `(.:?)` operator are changed. It's doesn't anymore accept
355 present `Null` value.
357* Added `(Foldable t, ToJSON a) => ToJSON (t a)` overlappable instance.
358 You might see `No instance for (Foldable YourPolymorphicType) arising from a
359 use of ‘.=’` -errors due this change.
361# 0.9.0.1
363* A stray export of `encodeToBuilder` got away!
365# 0.9.0.0
367* The `json` and `json'` parsers are now synonyms for `value` and
368 `value'`, in conformance with the looser semantics of RFC 7159.
370* Renamed `encodeToByteStringBuilder` to the more compact
371 `encodeToBuilder`.
373# 0.8.1.1
375* The dependency on the `unordered-containers` package was too lax,
376 and has been corrected.
378# 0.8.1.0
380* Encoding a `Scientific` value with a huge exponent is now handled
381 efficiently. (This would previously allocate a huge
382 arbitrary-precision integer, potentially leading to a denial of
383 service.)
385* Handling of strings that contain backslash escape sequences is
386 greatly improved. For a pathological string containing almost a
387 megabyte of consecutive backslashes, the new implementation is 27x
388 faster and uses 42x less memory.
390* The `ToJSON` instance for `UTCTime` is rendered with higher
391 (picosecond) resolution.
393* The `value` parser now correctly handles leading whitespace.
395* New instances of `ToJSON` and `FromJSON` for `Data.Sequence` and
396 `Data.Functor.Identity`. The `Value` type now has a `Read` instance.
398* `ZonedTime` parser ordering now favours the standard `JSON` format,
399 increasing efficiency in the common case.
401* Encoding to a `Text.Builder` now escapes `'<'` and `'>'` characters,
402 to reduce XSS risk.
404# 0.8.0.2
406* Fix `ToJSON` instance for 15-tuples (see #223).
408# 0.8.0.1
410* Support `time-1.5`.
412# 0.8.0.0
414* Add `ToJSON` and `FromJSON` instances for tuples of up to 15
415 elements.
417# 0.7.1.0
419* Major compiler and library compatibility changes: we have dropped
420 support for GHC older than 7.4, `text` older than 1.1, and
421 `bytestring` older than 0.10.4.0. Supporting the older versions had
422 become increasingly difficult, to the point where it was no longer
423 worth it.
425# 0.7.0.0
427* The performance of encoding to and decoding of bytestrings have both
428 improved by up to 2x, while also using less memory.
430* New dependency: the `scientific` package lets us parse floating point
431 numbers more quickly and accurately.
433* `eitherDecode`, `decodeStrictWith`: fixed bugs.
435* Added `FromJSON` and `ToJSON` instances for `Tree` and `Scientific`.
437* Fixed the `ToJSON` instances for `UTCTime` and `ZonedTime`.
439# 0.6 series
441* Much improved documentation.
443* Angle brackets are now escaped in JSON strings, to help avoid XSS
444 attacks.
446* Fixed up handling of nullary constructors when using generic
447 encoding.
449* Added `ToJSON`/`FromJSON` instances for:
451 * The `Fixed` class
452 * ISO-8601 dates: `UTCTime`, `ZonedTime`, and `TimeZone`
454* Added accessor functions for inspecting `Value`s.
456* Added `eitherDecode` function that returns an error message if
457 decoding fails.
459# 0.5 to 0.6
461* This release introduces a slightly obscure, but
462 backwards-incompatible, change.
464 In the generic APIs of versions 0.4 and 0.5, fields whose names
465 began with a `"_"` character would have this character removed. This
466 no longer occurs, as it was both buggy and surprising
467 (https://github.com/bos/aeson/issues/53).
469* Fixed a bug in generic decoding of nullary constructors
470 (https://github.com/bos/aeson/issues/62).
472# 0.4 to 0.5
474* When used with the UTF-8 encoding performance improvements
475 introduced in version 0.11.1.12 of the `text` package, this release
476 improves `aeson`'s JSON encoding performance by 33% relative to
477 `aeson` 0.4.
479 As part of achieving this improvement, an API change was necessary.
480 The `fromValue` function in the `Data.Aeson.Encode` module now uses
481 the `text` package's `Builder` type instead of the `blaze-builder`
482 package's `Builder` type.
484# 0.3 to 0.4
486* The new `decode` function complements the longstanding `encode`
487 function, and makes the API simpler.
489* New examples make it easier to learn to use the package
490 (https://github.com/bos/aeson/tree/master/examples).
492* Generics support
494 `aeson`'s support for data-type generic programming makes it
495 possible to use JSON encodings of most data types without writing
496 any boilerplate instances.
498 Thanks to Bas Van Dijk, `aeson` now supports the two major schemes
499 for doing datatype-generic programming:
501 * the modern mechanism, built into GHC itself
502 (http://www.haskell.org/ghc/docs/latest/html/users_guide/generic-programming.html)
504 * the older mechanism, based on SYB (aka "scrap your
505 boilerplate")
507 The modern GHC-based generic mechanism is fast and terse: in fact,
508 its performance is generally comparable in performance to
509 hand-written and TH-derived `ToJSON` and `FromJSON` instances. To
510 see how to use GHC generics, refer to `examples/Generic.hs`.
512 The SYB-based generics support lives in `Data.Aeson.Generic` and is
513 provided mainly for users of GHC older than 7.2. SYB is far slower
514 (by about 10x) than the more modern generic mechanism. To see how
515 to use SYB generics, refer to `examples/GenericSYB.hs`.
517* We switched the intermediate representation of JSON objects from
518 `Data.Map` to `Data.HashMap` which has improved type conversion
519 performance.
521* Instances of `ToJSON` and `FromJSON` for tuples are between 45% and 70%
522 faster than in 0.3.
524* Evaluation control
526 This version of aeson makes explicit the decoupling between
527 *identifying* an element of a JSON document and *converting* it to
528 Haskell. See the `Data.Aeson.Parser` documentation for details.
530 The normal `aeson` `decode` function performs identification
531 strictly, but defers conversion until needed. This can result in
532 improved performance (e.g. if the results of some conversions are
533 never needed), but at a cost in increased memory consumption.
535 The new `decode'` function performs identification and conversion
536 immediately. This incurs an up-front cost in CPU cycles, but
537 reduces reduce memory consumption.