on 1.0.2.1 help sign in
typeable/aeson/changelog.md
461 lines 16 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.0.2.1
5* Fixes a regression where a bunch of valid characters caused an
6 "Invalid UTF8-Stream" error when decoding. Thanks to Vladimir
7 Shabanov who investigated and fixed this.
9### 1.0.2.0
11* Fixes a regression where it was no longer possible to derive
12 instances for types such as `data T a = T { f1 :: a, f2 :: Maybe a
13 }`.
15Thanks to Sean Leather for fixing this, and to Ryan Scott for helping out.
17### 1.0.1.0
19* Decoding performance has been significantly improved (see
20 https://github.com/bos/aeson/pull/452). Thanks to @winterland1989.
22* Add `ToJSON`/`FromJSON` instances for newtypes from
23 `Data.Semigroup`: `Min`, `Max`, `First`, `Last`, `WrappedMonoid`,
24 `Option`. Thanks to Lennart Spitzner.
26* Make the documentation for `.:!` more accurate. Thanks to Ian Jeffries.
28# 1.0.0.0
30Major enhancements:
32* Introduced new `FromJSONKey` and `ToJSONKey` type classes that are
33 used to encode maps without going through HashMap. This also allows arbitrary
34 serialization of keys where a string-like key will encode into an object and
35 other keys will encode into an array of key-value tuples.
37* Added higher rank classes: `ToJSON1`, `ToJSON2`, `FromJSON1`, and
38 `FromJSON2`.
40* Added `Data.Aeson.Encoding` with functions to safely write `ToJSON`
41 instances using `toEncoding`.
43Other enhancements:
45* 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:
46```
47flags:
48 aeson:
49 fast: true
50```
52* Added list specific members to `ToJSON` and `FromJSON` classes. In
53 the same way `Read` and `Show` handle lists specifically. This
54 removes need for overlapping instances to handle `String`.
56* Added a new `sumEncoding` option `UntaggedValue` which prevents
57 objects from being tagged with the constructor name.
59* JSONPaths are now tracked in instances derived with template-haskell
60 and generics.
62* Get rid of redundancy of JSONPath error messages in nested records.
64 `eitherDecode "{\"x\":{\"a\": [1,2,true]}}" :: Either String Y`
65 previously yielded
66 `Error in $.x.a[2]: failed to parse field" x: failed to parse field a: expected Int, encountered Boolean`
67 and now yields `Error in $.x.a[2]: expected Int, encountered Boolean"`.
69 Some users might prefer to insert `modifyFailure` themselves to
70 customize error messages, which previously prevented the use of
71 `(.:)`.
73* Backwards compatibility with `bytestring-0.9` using the
74 `bytestring-builder` compatibility package.
76* Export `decodeWith`, `decodeStrictWith`, `eitherDecodeWith`, and
77 `eitherDecodeStrictWith` from `Data.Aeson.Parser`. This allows
78 decoding using explicit parsers instead of using `FromJSON`
79 instances.
81* Un-orphan internal instances to render them in haddocks.
83Other changes:
85* Integral `FromJSON` instances now only accept integral
86 values. E.g. parsing `3.14` to `Int` fails instead of succeeding
87 with the value `3`.
89* Over/underflows are now caught for bounded numeric types.
91* Remove the `contents` field encoding with `allNullaryToStringTag = False`,
92 giving us `{ "tag" : "c1" }` instead of `{ "tag" : "c1", contents : [] }`.
93 The contents field is optional when parsing so this is only a breaking
94 change for ToJSON instances.
96* Fix a bug where `genericToEncoding` with `unwrapUnaryRecords = True`
97 would produce an invalid encoding: `"unwrap\":""`.
99* `ToJSON` instances using `genericToEncoding` and `omitNothingFields`
100 no longer produce invalid JSON.
102* Added instances for `DList`, `Compose`, `Product`, `Sum`.
104### 0.11.2.0
106* Enable `PolyKinds` to generalize `Proxy`, `Tagged`, and `Const` instances.
107* Add `unsafeToEncoding` in `Data.Aeson.Types`, use with care!
109#### 0.11.1.4
111* Fix build with `base >= 4.8` and `unordered-containers < 0.2.6`.
113#### 0.11.1.3
115* Fix build on TH-less GHCs
117#### 0.11.1.2
119* Fix build with `base < 4.8` and `unordered-containers < 0.2.6`.
120* Add missing field in docs for `defaultOptions`.
122#### 0.11.1.1
124* Fixes a bug where the hashes of equal values could differ.
126### 0.11.1.0
128The only changes are added instances.
130These are new:
131* `ToJSON a => ToJSON (NonEmpty a)`
132* `FromJSON a => FromJSON (NonEmpty a)`
133* `ToJSON (Proxy a)`
134* `FromJSON (Proxy a)`
135* `ToJSON b => ToJSON (Tagged a b)`
136* `FromJSON b => FromJSON (Tagged a b)`
137* `ToJSON a => ToJSON (Const a b)`
138* `FromJSON a => FromJSON (Const a b)`
140These are now available for older GHCs:
141* `ToJSON Natural`
142* `FromJSON Natural`
144# 0.11.0.0
146This release should be close to backwards compatible with aeson 0.9.
148If you are upgrading from aeson 0.10 it might be easier to go back in
149history to the point you were still using 0.9.
151**Breaking changes**:
153* Revert `.:?` to behave like it did in 0.9. If you want the 0.10
154 behavior use `.:!` instead.
156* Revert JSON format of `Either` to 0.9, `Left` and `Right` are now
157 serialized with an initial uppercase letter. If you want the names
158 in lowercase you can add a newtype with an instance.
160* All `ToJSON` and `FromJSON` instances except for `[a]` are no longer
161 `OVERLAPPABLE`. Mark your instance as `OVERLAPPING` if it overlaps
162 any of the other aeson instances.
164* All `ToJSON` and `FromJSON` instances except for `[Char]` are no
165 longer incoherent, this means you may need to replace your
166 incoherent instances with a newtyped instance.
168**Additions**:
170* Introduce `.:!` that behaves like `.:?` did in 0.10.
172* Allow `HH:MM` format for `ZonedTime` and `UTCTime`.
173 This is one of the formats allowed by
174 [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#Times).
176* Added `ToJSON` and `FromJSON` instances for the
177 `Version`, `Ordering`, and `Natural` types.
179**Bug fixes**:
181* JSONPath identifiers are now escaped if they contain invalid characters.
183* Fixed JSONPath messages for Seq to include indices.
185* Fixed JSONPath messages for Either to include `left`/`right`.
187* Fix missing quotes surrounding time encodings.
189* Fix #293: Type error in TH when using `omitNothingFields = True`.
191**Compatibility**:
193* Various updates to support GHC 8.
196# 0.10.0.0
198## Performance improvements
200* Direct encoding via the new `toEncoding` method is over 2x faster
201 than `toJSON`. (You must write or code-gen a `toEncoding`
202 implementation to unlock this speedup. See below for details.)
204* Improved string decoding gives a 12% speed win in parsing
205 string-heavy JSON payloads (very common).
207* Encoding and decoding of time-related types are 10x faster (!!) as a
208 result of bypassing `Data.Time.Format` and the arbitrary-precision
209 `Integer` type.
211* When using `toEncoding`, `[Char]` can be encoded without a conversion to
212 `Text`. This is fast and efficient.
214* Parsing into an `Object` is now 5% faster and more
215 allocation-efficient.
217## SUBTLE API CHANGES, READ CAREFULLY
219With the exception of long-deprecated code, the API changes below
220**should be upwards compatible** from older versions of `aeson`. If you run
221into upgrade problems, please file an issue with details.
223* The `ToJSON` class has a new method, `toEncoding`, that allows
224 direct encoding from a Haskell value to a lazy bytestring without
225 construction of an intermediate `Value`.
227 The performance benefits of direct encoding are significant: more
228 than 2x faster than before, with less than 1/3 the memory usage.
230 To preserve API compatibility across upgrades from older versions of
231 this library, the default implementation of `toEncoding` uses
232 `toJSON`. You will *not* see any performance improvement unless you
233 write an implementation of `toEncoding`, which can be very simple:
235 ```haskell
236 instance ToJSON Coord where
237 toEncoding = genericToEncoding defaultOptions
238 ```
240 (Behind the scenes, the `encode` function uses `toEncoding` now, so
241 if you implement `toEncoding` for your types, you should see a
242 speedup immediately.)
244 If you use Template Haskell or GHC Generics to auto-generate your
245 `ToJSON` instances, you'll benefit from fast toEncoding
246 implementations for free!
248* When converting from a `Value` to a target Haskell type, `FromJSON`
249 instances now provide much better error messages, including a
250 complete JSON path from the root of the object to the offending
251 element. This greatly eases debugging.
253* It is now possible to use Template Haskell to generate `FromJSON`
254 and `ToJSON` instances for types in data families.
256* If you use Template Haskell or generics, and used to use the
257 `camelTo` function to rename fields, the new `camelTo2` function is
258 smarter. For example, `camelTo` will rename `CamelAPICase` to
259 `camelapi_case` (ugh!), while `camelTo2` will map it to
260 `camel_api_case` (yay!).
262* New `ToJSON` and `FromJSON` instances for the following time-related
263 types: `Day`, `LocalTime`.
265* `FromJSON` `UTCTime` parser accepts the same values as for `ZonedTime`,
266 but converts any time zone offset into a UTC time.
268* The `Result` type is now an instance of `Foldable` and `Traversable`.
270* The `Data.Aeson.Generic` module has been removed. It was deprecated in
271 late 2013.
273* GHC 7.2 and older are no longer supported.
275* The instance of `Monad` for the `Result` type lacked an implementation
276 of `fail` (oops). This has been corrected.
278* Semantics of `(.:?)` operator are changed. It's doesn't anymore accept
279 present `Null` value.
281* Added `(Foldable t, ToJSON a) => ToJSON (t a)` overlappable instance.
282 You might see `No instance for (Foldable YourPolymorphicType) arising from a
283 use of ‘.=’` -errors due this change.
285# 0.9.0.1
287* A stray export of `encodeToBuilder` got away!
289# 0.9.0.0
291* The `json` and `json'` parsers are now synonyms for `value` and
292 `value'`, in conformance with the looser semantics of RFC 7159.
294* Renamed `encodeToByteStringBuilder` to the more compact
295 `encodeToBuilder`.
297# 0.8.1.1
299* The dependency on the `unordered-containers` package was too lax,
300 and has been corrected.
302# 0.8.1.0
304* Encoding a `Scientific` value with a huge exponent is now handled
305 efficiently. (This would previously allocate a huge
306 arbitrary-precision integer, potentially leading to a denial of
307 service.)
309* Handling of strings that contain backslash escape sequences is
310 greatly improved. For a pathological string containing almost a
311 megabyte of consecutive backslashes, the new implementation is 27x
312 faster and uses 42x less memory.
314* The `ToJSON` instance for `UTCTime` is rendered with higher
315 (picosecond) resolution.
317* The `value` parser now correctly handles leading whitespace.
319* New instances of `ToJSON` and `FromJSON` for `Data.Sequence` and
320 `Data.Functor.Identity`. The `Value` type now has a `Read` instance.
322* `ZonedTime` parser ordering now favours the standard `JSON` format,
323 increasing efficiency in the common case.
325* Encoding to a `Text.Builder` now escapes `'<'` and `'>'` characters,
326 to reduce XSS risk.
328# 0.8.0.2
330* Fix `ToJSON` instance for 15-tuples (see #223).
332# 0.8.0.1
334* Support `time-1.5`.
336# 0.8.0.0
338* Add `ToJSON` and `FromJSON` instances for tuples of up to 15
339 elements.
341# 0.7.1.0
343* Major compiler and library compatibility changes: we have dropped
344 support for GHC older than 7.4, `text` older than 1.1, and
345 `bytestring` older than 0.10.4.0. Supporting the older versions had
346 become increasingly difficult, to the point where it was no longer
347 worth it.
349# 0.7.0.0
351* The performance of encoding to and decoding of bytestrings have both
352 improved by up to 2x, while also using less memory.
354* New dependency: the `scientific` package lets us parse floating point
355 numbers more quickly and accurately.
357* `eitherDecode`, `decodeStrictWith`: fixed bugs.
359* Added `FromJSON` and `ToJSON` instances for `Tree` and `Scientific`.
361* Fixed the `ToJSON` instances for `UTCTime` and `ZonedTime`.
363# 0.6 series
365* Much improved documentation.
367* Angle brackets are now escaped in JSON strings, to help avoid XSS
368 attacks.
370* Fixed up handling of nullary constructors when using generic
371 encoding.
373* Added `ToJSON`/`FromJSON` instances for:
375 * The `Fixed` class
376 * ISO-8601 dates: `UTCTime`, `ZonedTime`, and `TimeZone`
378* Added accessor functions for inspecting `Value`s.
380* Added `eitherDecode` function that returns an error message if
381 decoding fails.
383# 0.5 to 0.6
385* This release introduces a slightly obscure, but
386 backwards-incompatible, change.
388 In the generic APIs of versions 0.4 and 0.5, fields whose names
389 began with a `"_"` character would have this character removed. This
390 no longer occurs, as it was both buggy and surprising
391 (https://github.com/bos/aeson/issues/53).
393* Fixed a bug in generic decoding of nullary constructors
394 (https://github.com/bos/aeson/issues/62).
396# 0.4 to 0.5
398* When used with the UTF-8 encoding performance improvements
399 introduced in version 0.11.1.12 of the `text` package, this release
400 improves `aeson`'s JSON encoding performance by 33% relative to
401 `aeson` 0.4.
403 As part of achieving this improvement, an API change was necessary.
404 The `fromValue` function in the `Data.Aeson.Encode` module now uses
405 the `text` package's `Builder` type instead of the `blaze-builder`
406 package's `Builder` type.
408# 0.3 to 0.4
410* The new `decode` function complements the longstanding `encode`
411 function, and makes the API simpler.
413* New examples make it easier to learn to use the package
414 (https://github.com/bos/aeson/tree/master/examples).
416* Generics support
418 `aeson`'s support for data-type generic programming makes it
419 possible to use JSON encodings of most data types without writing
420 any boilerplate instances.
422 Thanks to Bas Van Dijk, `aeson` now supports the two major schemes
423 for doing datatype-generic programming:
425 * the modern mechanism, built into GHC itself
426 (http://www.haskell.org/ghc/docs/latest/html/users_guide/generic-programming.html)
428 * the older mechanism, based on SYB (aka "scrap your
429 boilerplate")
431 The modern GHC-based generic mechanism is fast and terse: in fact,
432 its performance is generally comparable in performance to
433 hand-written and TH-derived `ToJSON` and `FromJSON` instances. To
434 see how to use GHC generics, refer to `examples/Generic.hs`.
436 The SYB-based generics support lives in `Data.Aeson.Generic` and is
437 provided mainly for users of GHC older than 7.2. SYB is far slower
438 (by about 10x) than the more modern generic mechanism. To see how
439 to use SYB generics, refer to `examples/GenericSYB.hs`.
441* We switched the intermediate representation of JSON objects from
442 `Data.Map` to `Data.HashMap` which has improved type conversion
443 performance.
445* Instances of `ToJSON` and `FromJSON` for tuples are between 45% and 70%
446 faster than in 0.3.
448* Evaluation control
450 This version of aeson makes explicit the decoupling between
451 *identifying* an element of a JSON document and *converting* it to
452 Haskell. See the `Data.Aeson.Parser` documentation for details.
454 The normal `aeson` `decode` function performs identification
455 strictly, but defers conversion until needed. This can result in
456 improved performance (e.g. if the results of some conversions are
457 never needed), but at a cost in increased memory consumption.
459 The new `decode'` function performs identification and conversion
460 immediately. This incurs an up-front cost in CPU cycles, but
461 reduces reduce memory consumption.