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