|
Packit |
9a2dfb |
For 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).
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
### 1.2.3.0
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Added `withEmbeddedJSON` to help parse JSON embedded inside a JSON string, thanks to Jesse Kempf.
|
|
Packit |
9a2dfb |
* Memory usage improvements to the default (pure) parser, thanks to Jonathan Paugh. Also thanks to Neil Mitchell & Oleg Grenrus for contributing a benchmark.
|
|
Packit |
9a2dfb |
* `omitNothingFields` now works for the `Option` newtype, thanks to Xia Li-yao.
|
|
Packit |
9a2dfb |
* Some documentation fixes, thanks to Jonathan Paug & Philippe Crama.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
### 1.2.2.0
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Add `FromJSON` and `ToJSON` instances for
|
|
Packit |
9a2dfb |
* `DiffTime`, thanks to Víctor López Juan.
|
|
Packit |
9a2dfb |
* `CTime`, thanks to Daniel Díaz.
|
|
Packit |
9a2dfb |
* Fix handling of fractions when parsing Natural, thanks to Yuriy Syrovetskiy.
|
|
Packit |
9a2dfb |
* Change text in error messages for Integral types to make them follow the common pattern, thanks to Yuriy Syrovetskiy.
|
|
Packit |
9a2dfb |
* Add missing `INCOHERENT` pragma for `RecordToPair`, thanks to Xia Li-yao.
|
|
Packit |
9a2dfb |
* Everything related to `Options` is now exported from `Data.Aeson`, thanks to Xia Li-yao.
|
|
Packit |
9a2dfb |
* Optimizations to not escape text in clear cases, thanks to Oleg Grenrus.
|
|
Packit |
9a2dfb |
* Some documentation fixes, thanks to Phil de Joux & Xia Li-yao.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
### 1.2.1.0
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Add `parserThrowError` and `parserCatchError` combinators, thanks to Oleg Grenrus.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Add `Generic` instance for `Value`, thanks to Xia Li-yao.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Fix a mistake in the 1.2.0.0 changelog, the `cffi` flag is disabled by default! Thanks to dbaynard.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
## 1.2.0.0
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* `tagSingleConstructors`, an option to encode single-constructor types as tagged sums was added to `Options`. It is disabled by default for backward compatibility.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* 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.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* The `Options` constructor is no longer exposed to prevent new options from being breaking changes, use `defaultOptions` instead.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* The contents of `GToJSON` and `GToEncoding` are no longer exposed.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Some INLINE pragmas were removed to avoid GHC running out of simplifier ticks.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
### 1.1.2.0
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Fix an accidental change in the format of `deriveJSON`. Thanks to Xia Li-yao!
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Documentation improvements regarding `ToJSON`, `FromJSON`, and `SumEncoding`. Thanks to Xia Li-yao and Lennart Spitzner!
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
### 1.1.1.0
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* 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!
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* 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!
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
## 1.1.0.0
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Added instances for `UUID`.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* The operators for parsing fields now have named aliases:
|
|
Packit |
9a2dfb |
- `.:` => `parseField`
|
|
Packit |
9a2dfb |
- `.:?` => `parseFieldMaybe`
|
|
Packit |
9a2dfb |
- `.:!` => `parseFieldMaybe'`
|
|
Packit |
9a2dfb |
- These functions now also have variants with explicit parser functions: `explicitParseField`, `explicitParseFieldMaybe`, "explicitParseFieldMaybe'`
|
|
Packit |
9a2dfb |
Thanks to Oleg Grenrus.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* `ToJSONKey (Identity a)` and `FromJSONKey (Identity a)` no longer require the unnecessary `FromJSON a` constraint. Thanks to Oleg Grenrus.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Added `Data.Aeson.Encoding.pair'` which is a more general version of `Data.Aeson.Encoding.pair`. Thanks to Andrew Martin.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* `Day`s BCE are properly encoded and `+` is now a valid prefix for `Day`s CE. Thanks to Matt Parsons.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Some commonly used ToJSON instances are now specialized in order to improve compile time. Thanks to Bartosz Nitka.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
[JSONTestSuite](https://github.com/nst/JSONTestSuite) cleanups, all
|
|
Packit |
9a2dfb |
motivated by tighter RFC 7159 compliance:
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* The parser now rejects numbers for which
|
|
Packit |
9a2dfb |
[the integer portion contains a leading zero](https://github.com/bos/aeson/commit/3fb7c155f2255482b1b9566ec5c1eaf9895d630e).
|
|
Packit |
9a2dfb |
* The parser now rejects numbers for which
|
|
Packit |
9a2dfb |
[a decimal point is not followed by at least one digit](https://github.com/bos/aeson/commit/ecfca35a45286dbe2bbaf5f62354be393bc59b66),
|
|
Packit |
9a2dfb |
* The parser now rejects documents that contain [whitespace outside the
|
|
Packit |
9a2dfb |
set {space, newline, carriage return, tab}](https://github.com/bos/aeson/commit/8ef622c2ad8d4a109884e17c2792238a2a320e44).
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
Over 90% of JSONTestSuite tests currently pass. The remainder can be
|
|
Packit |
9a2dfb |
categorised as follows:
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* The string parser is strict with Unicode compliance where the RFC
|
|
Packit |
9a2dfb |
leaves room for implementation-defined behaviour (tests prefixed
|
|
Packit |
9a2dfb |
with "`i_string_`". (This is necessary because the `text` library
|
|
Packit |
9a2dfb |
cannot accommodate invalid Unicode.)
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* The parser does not (and will not) support UTF-16, UTF-32, or byte
|
|
Packit |
9a2dfb |
order marks (BOM).
|
|
Packit |
9a2dfb |
* The parser accepts unescaped control characters, even though the RFC
|
|
Packit |
9a2dfb |
states that control characters must be escaped. (This may change at
|
|
Packit |
9a2dfb |
some point, but doesn't seem important.)
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
#### 1.0.2.1
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Fixes a regression where a bunch of valid characters caused an
|
|
Packit |
9a2dfb |
"Invalid UTF8-Stream" error when decoding. Thanks to Vladimir
|
|
Packit |
9a2dfb |
Shabanov who investigated and fixed this.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
### 1.0.2.0
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Fixes a regression where it was no longer possible to derive
|
|
Packit |
9a2dfb |
instances for types such as `data T a = T { f1 :: a, f2 :: Maybe a
|
|
Packit |
9a2dfb |
}`.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
Thanks to Sean Leather for fixing this, and to Ryan Scott for helping out.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
### 1.0.1.0
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Decoding performance has been significantly improved (see
|
|
Packit |
9a2dfb |
https://github.com/bos/aeson/pull/452). Thanks to @winterland1989.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Add `ToJSON`/`FromJSON` instances for newtypes from
|
|
Packit |
9a2dfb |
`Data.Semigroup`: `Min`, `Max`, `First`, `Last`, `WrappedMonoid`,
|
|
Packit |
9a2dfb |
`Option`. Thanks to Lennart Spitzner.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Make the documentation for `.:!` more accurate. Thanks to Ian Jeffries.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
# 1.0.0.0
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
Major enhancements:
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Introduced new `FromJSONKey` and `ToJSONKey` type classes that are
|
|
Packit |
9a2dfb |
used to encode maps without going through HashMap. This also allows arbitrary
|
|
Packit |
9a2dfb |
serialization of keys where a string-like key will encode into an object and
|
|
Packit |
9a2dfb |
other keys will encode into an array of key-value tuples.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Added higher rank classes: `ToJSON1`, `ToJSON2`, `FromJSON1`, and
|
|
Packit |
9a2dfb |
`FromJSON2`.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Added `Data.Aeson.Encoding` with functions to safely write `ToJSON`
|
|
Packit |
9a2dfb |
instances using `toEncoding`.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
Other enhancements:
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* 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:
|
|
Packit |
9a2dfb |
```
|
|
Packit |
9a2dfb |
flags:
|
|
Packit |
9a2dfb |
aeson:
|
|
Packit |
9a2dfb |
fast: true
|
|
Packit |
9a2dfb |
```
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Added list specific members to `ToJSON` and `FromJSON` classes. In
|
|
Packit |
9a2dfb |
the same way `Read` and `Show` handle lists specifically. This
|
|
Packit |
9a2dfb |
removes need for overlapping instances to handle `String`.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Added a new `sumEncoding` option `UntaggedValue` which prevents
|
|
Packit |
9a2dfb |
objects from being tagged with the constructor name.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* JSONPaths are now tracked in instances derived with template-haskell
|
|
Packit |
9a2dfb |
and generics.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Get rid of redundancy of JSONPath error messages in nested records.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
`eitherDecode "{\"x\":{\"a\": [1,2,true]}}" :: Either String Y`
|
|
Packit |
9a2dfb |
previously yielded
|
|
Packit |
9a2dfb |
`Error in $.x.a[2]: failed to parse field" x: failed to parse field a: expected Int, encountered Boolean`
|
|
Packit |
9a2dfb |
and now yields `Error in $.x.a[2]: expected Int, encountered Boolean"`.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
Some users might prefer to insert `modifyFailure` themselves to
|
|
Packit |
9a2dfb |
customize error messages, which previously prevented the use of
|
|
Packit |
9a2dfb |
`(.:)`.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Backwards compatibility with `bytestring-0.9` using the
|
|
Packit |
9a2dfb |
`bytestring-builder` compatibility package.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Export `decodeWith`, `decodeStrictWith`, `eitherDecodeWith`, and
|
|
Packit |
9a2dfb |
`eitherDecodeStrictWith` from `Data.Aeson.Parser`. This allows
|
|
Packit |
9a2dfb |
decoding using explicit parsers instead of using `FromJSON`
|
|
Packit |
9a2dfb |
instances.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Un-orphan internal instances to render them in haddocks.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
Other changes:
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Integral `FromJSON` instances now only accept integral
|
|
Packit |
9a2dfb |
values. E.g. parsing `3.14` to `Int` fails instead of succeeding
|
|
Packit |
9a2dfb |
with the value `3`.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Over/underflows are now caught for bounded numeric types.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Remove the `contents` field encoding with `allNullaryToStringTag = False`,
|
|
Packit |
9a2dfb |
giving us `{ "tag" : "c1" }` instead of `{ "tag" : "c1", contents : [] }`.
|
|
Packit |
9a2dfb |
The contents field is optional when parsing so this is only a breaking
|
|
Packit |
9a2dfb |
change for ToJSON instances.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Fix a bug where `genericToEncoding` with `unwrapUnaryRecords = True`
|
|
Packit |
9a2dfb |
would produce an invalid encoding: `"unwrap\":""`.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* `ToJSON` instances using `genericToEncoding` and `omitNothingFields`
|
|
Packit |
9a2dfb |
no longer produce invalid JSON.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Added instances for `DList`, `Compose`, `Product`, `Sum`.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
### 0.11.2.0
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Enable `PolyKinds` to generalize `Proxy`, `Tagged`, and `Const` instances.
|
|
Packit |
9a2dfb |
* Add `unsafeToEncoding` in `Data.Aeson.Types`, use with care!
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
#### 0.11.1.4
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Fix build with `base >= 4.8` and `unordered-containers < 0.2.6`.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
#### 0.11.1.3
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Fix build on TH-less GHCs
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
#### 0.11.1.2
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Fix build with `base < 4.8` and `unordered-containers < 0.2.6`.
|
|
Packit |
9a2dfb |
* Add missing field in docs for `defaultOptions`.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
#### 0.11.1.1
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Fixes a bug where the hashes of equal values could differ.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
### 0.11.1.0
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
The only changes are added instances.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
These are new:
|
|
Packit |
9a2dfb |
* `ToJSON a => ToJSON (NonEmpty a)`
|
|
Packit |
9a2dfb |
* `FromJSON a => FromJSON (NonEmpty a)`
|
|
Packit |
9a2dfb |
* `ToJSON (Proxy a)`
|
|
Packit |
9a2dfb |
* `FromJSON (Proxy a)`
|
|
Packit |
9a2dfb |
* `ToJSON b => ToJSON (Tagged a b)`
|
|
Packit |
9a2dfb |
* `FromJSON b => FromJSON (Tagged a b)`
|
|
Packit |
9a2dfb |
* `ToJSON a => ToJSON (Const a b)`
|
|
Packit |
9a2dfb |
* `FromJSON a => FromJSON (Const a b)`
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
These are now available for older GHCs:
|
|
Packit |
9a2dfb |
* `ToJSON Natural`
|
|
Packit |
9a2dfb |
* `FromJSON Natural`
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
# 0.11.0.0
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
This release should be close to backwards compatible with aeson 0.9.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
If you are upgrading from aeson 0.10 it might be easier to go back in
|
|
Packit |
9a2dfb |
history to the point you were still using 0.9.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
**Breaking changes**:
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Revert `.:?` to behave like it did in 0.9. If you want the 0.10
|
|
Packit |
9a2dfb |
behavior use `.:!` instead.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Revert JSON format of `Either` to 0.9, `Left` and `Right` are now
|
|
Packit |
9a2dfb |
serialized with an initial uppercase letter. If you want the names
|
|
Packit |
9a2dfb |
in lowercase you can add a newtype with an instance.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* All `ToJSON` and `FromJSON` instances except for `[a]` are no longer
|
|
Packit |
9a2dfb |
`OVERLAPPABLE`. Mark your instance as `OVERLAPPING` if it overlaps
|
|
Packit |
9a2dfb |
any of the other aeson instances.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* All `ToJSON` and `FromJSON` instances except for `[Char]` are no
|
|
Packit |
9a2dfb |
longer incoherent, this means you may need to replace your
|
|
Packit |
9a2dfb |
incoherent instances with a newtyped instance.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
**Additions**:
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Introduce `.:!` that behaves like `.:?` did in 0.10.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Allow `HH:MM` format for `ZonedTime` and `UTCTime`.
|
|
Packit |
9a2dfb |
This is one of the formats allowed by
|
|
Packit |
9a2dfb |
[ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#Times).
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Added `ToJSON` and `FromJSON` instances for the
|
|
Packit |
9a2dfb |
`Version`, `Ordering`, and `Natural` types.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
**Bug fixes**:
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* JSONPath identifiers are now escaped if they contain invalid characters.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Fixed JSONPath messages for Seq to include indices.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Fixed JSONPath messages for Either to include `left`/`right`.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Fix missing quotes surrounding time encodings.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Fix #293: Type error in TH when using `omitNothingFields = True`.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
**Compatibility**:
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Various updates to support GHC 8.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
# 0.10.0.0
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
## Performance improvements
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Direct encoding via the new `toEncoding` method is over 2x faster
|
|
Packit |
9a2dfb |
than `toJSON`. (You must write or code-gen a `toEncoding`
|
|
Packit |
9a2dfb |
implementation to unlock this speedup. See below for details.)
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Improved string decoding gives a 12% speed win in parsing
|
|
Packit |
9a2dfb |
string-heavy JSON payloads (very common).
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Encoding and decoding of time-related types are 10x faster (!!) as a
|
|
Packit |
9a2dfb |
result of bypassing `Data.Time.Format` and the arbitrary-precision
|
|
Packit |
9a2dfb |
`Integer` type.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* When using `toEncoding`, `[Char]` can be encoded without a conversion to
|
|
Packit |
9a2dfb |
`Text`. This is fast and efficient.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Parsing into an `Object` is now 5% faster and more
|
|
Packit |
9a2dfb |
allocation-efficient.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
## SUBTLE API CHANGES, READ CAREFULLY
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
With the exception of long-deprecated code, the API changes below
|
|
Packit |
9a2dfb |
**should be upwards compatible** from older versions of `aeson`. If you run
|
|
Packit |
9a2dfb |
into upgrade problems, please file an issue with details.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* The `ToJSON` class has a new method, `toEncoding`, that allows
|
|
Packit |
9a2dfb |
direct encoding from a Haskell value to a lazy bytestring without
|
|
Packit |
9a2dfb |
construction of an intermediate `Value`.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
The performance benefits of direct encoding are significant: more
|
|
Packit |
9a2dfb |
than 2x faster than before, with less than 1/3 the memory usage.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
To preserve API compatibility across upgrades from older versions of
|
|
Packit |
9a2dfb |
this library, the default implementation of `toEncoding` uses
|
|
Packit |
9a2dfb |
`toJSON`. You will *not* see any performance improvement unless you
|
|
Packit |
9a2dfb |
write an implementation of `toEncoding`, which can be very simple:
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
```haskell
|
|
Packit |
9a2dfb |
instance ToJSON Coord where
|
|
Packit |
9a2dfb |
toEncoding = genericToEncoding defaultOptions
|
|
Packit |
9a2dfb |
```
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
(Behind the scenes, the `encode` function uses `toEncoding` now, so
|
|
Packit |
9a2dfb |
if you implement `toEncoding` for your types, you should see a
|
|
Packit |
9a2dfb |
speedup immediately.)
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
If you use Template Haskell or GHC Generics to auto-generate your
|
|
Packit |
9a2dfb |
`ToJSON` instances, you'll benefit from fast toEncoding
|
|
Packit |
9a2dfb |
implementations for free!
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* When converting from a `Value` to a target Haskell type, `FromJSON`
|
|
Packit |
9a2dfb |
instances now provide much better error messages, including a
|
|
Packit |
9a2dfb |
complete JSON path from the root of the object to the offending
|
|
Packit |
9a2dfb |
element. This greatly eases debugging.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* It is now possible to use Template Haskell to generate `FromJSON`
|
|
Packit |
9a2dfb |
and `ToJSON` instances for types in data families.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* If you use Template Haskell or generics, and used to use the
|
|
Packit |
9a2dfb |
`camelTo` function to rename fields, the new `camelTo2` function is
|
|
Packit |
9a2dfb |
smarter. For example, `camelTo` will rename `CamelAPICase` to
|
|
Packit |
9a2dfb |
`camelapi_case` (ugh!), while `camelTo2` will map it to
|
|
Packit |
9a2dfb |
`camel_api_case` (yay!).
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* New `ToJSON` and `FromJSON` instances for the following time-related
|
|
Packit |
9a2dfb |
types: `Day`, `LocalTime`.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* `FromJSON` `UTCTime` parser accepts the same values as for `ZonedTime`,
|
|
Packit |
9a2dfb |
but converts any time zone offset into a UTC time.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* The `Result` type is now an instance of `Foldable` and `Traversable`.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* The `Data.Aeson.Generic` module has been removed. It was deprecated in
|
|
Packit |
9a2dfb |
late 2013.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* GHC 7.2 and older are no longer supported.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* The instance of `Monad` for the `Result` type lacked an implementation
|
|
Packit |
9a2dfb |
of `fail` (oops). This has been corrected.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Semantics of `(.:?)` operator are changed. It's doesn't anymore accept
|
|
Packit |
9a2dfb |
present `Null` value.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Added `(Foldable t, ToJSON a) => ToJSON (t a)` overlappable instance.
|
|
Packit |
9a2dfb |
You might see `No instance for (Foldable YourPolymorphicType) arising from a
|
|
Packit |
9a2dfb |
use of ‘.=’` -errors due this change.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
# 0.9.0.1
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* A stray export of `encodeToBuilder` got away!
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
# 0.9.0.0
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* The `json` and `json'` parsers are now synonyms for `value` and
|
|
Packit |
9a2dfb |
`value'`, in conformance with the looser semantics of RFC 7159.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Renamed `encodeToByteStringBuilder` to the more compact
|
|
Packit |
9a2dfb |
`encodeToBuilder`.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
# 0.8.1.1
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* The dependency on the `unordered-containers` package was too lax,
|
|
Packit |
9a2dfb |
and has been corrected.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
# 0.8.1.0
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Encoding a `Scientific` value with a huge exponent is now handled
|
|
Packit |
9a2dfb |
efficiently. (This would previously allocate a huge
|
|
Packit |
9a2dfb |
arbitrary-precision integer, potentially leading to a denial of
|
|
Packit |
9a2dfb |
service.)
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Handling of strings that contain backslash escape sequences is
|
|
Packit |
9a2dfb |
greatly improved. For a pathological string containing almost a
|
|
Packit |
9a2dfb |
megabyte of consecutive backslashes, the new implementation is 27x
|
|
Packit |
9a2dfb |
faster and uses 42x less memory.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* The `ToJSON` instance for `UTCTime` is rendered with higher
|
|
Packit |
9a2dfb |
(picosecond) resolution.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* The `value` parser now correctly handles leading whitespace.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* New instances of `ToJSON` and `FromJSON` for `Data.Sequence` and
|
|
Packit |
9a2dfb |
`Data.Functor.Identity`. The `Value` type now has a `Read` instance.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* `ZonedTime` parser ordering now favours the standard `JSON` format,
|
|
Packit |
9a2dfb |
increasing efficiency in the common case.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Encoding to a `Text.Builder` now escapes `'<'` and `'>'` characters,
|
|
Packit |
9a2dfb |
to reduce XSS risk.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
# 0.8.0.2
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Fix `ToJSON` instance for 15-tuples (see #223).
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
# 0.8.0.1
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Support `time-1.5`.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
# 0.8.0.0
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Add `ToJSON` and `FromJSON` instances for tuples of up to 15
|
|
Packit |
9a2dfb |
elements.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
# 0.7.1.0
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Major compiler and library compatibility changes: we have dropped
|
|
Packit |
9a2dfb |
support for GHC older than 7.4, `text` older than 1.1, and
|
|
Packit |
9a2dfb |
`bytestring` older than 0.10.4.0. Supporting the older versions had
|
|
Packit |
9a2dfb |
become increasingly difficult, to the point where it was no longer
|
|
Packit |
9a2dfb |
worth it.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
# 0.7.0.0
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* The performance of encoding to and decoding of bytestrings have both
|
|
Packit |
9a2dfb |
improved by up to 2x, while also using less memory.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* New dependency: the `scientific` package lets us parse floating point
|
|
Packit |
9a2dfb |
numbers more quickly and accurately.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* `eitherDecode`, `decodeStrictWith`: fixed bugs.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Added `FromJSON` and `ToJSON` instances for `Tree` and `Scientific`.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Fixed the `ToJSON` instances for `UTCTime` and `ZonedTime`.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
# 0.6 series
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Much improved documentation.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Angle brackets are now escaped in JSON strings, to help avoid XSS
|
|
Packit |
9a2dfb |
attacks.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Fixed up handling of nullary constructors when using generic
|
|
Packit |
9a2dfb |
encoding.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Added `ToJSON`/`FromJSON` instances for:
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* The `Fixed` class
|
|
Packit |
9a2dfb |
* ISO-8601 dates: `UTCTime`, `ZonedTime`, and `TimeZone`
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Added accessor functions for inspecting `Value`s.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Added `eitherDecode` function that returns an error message if
|
|
Packit |
9a2dfb |
decoding fails.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
# 0.5 to 0.6
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* This release introduces a slightly obscure, but
|
|
Packit |
9a2dfb |
backwards-incompatible, change.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
In the generic APIs of versions 0.4 and 0.5, fields whose names
|
|
Packit |
9a2dfb |
began with a `"_"` character would have this character removed. This
|
|
Packit |
9a2dfb |
no longer occurs, as it was both buggy and surprising
|
|
Packit |
9a2dfb |
(https://github.com/bos/aeson/issues/53).
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Fixed a bug in generic decoding of nullary constructors
|
|
Packit |
9a2dfb |
(https://github.com/bos/aeson/issues/62).
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
# 0.4 to 0.5
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* When used with the UTF-8 encoding performance improvements
|
|
Packit |
9a2dfb |
introduced in version 0.11.1.12 of the `text` package, this release
|
|
Packit |
9a2dfb |
improves `aeson`'s JSON encoding performance by 33% relative to
|
|
Packit |
9a2dfb |
`aeson` 0.4.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
As part of achieving this improvement, an API change was necessary.
|
|
Packit |
9a2dfb |
The `fromValue` function in the `Data.Aeson.Encode` module now uses
|
|
Packit |
9a2dfb |
the `text` package's `Builder` type instead of the `blaze-builder`
|
|
Packit |
9a2dfb |
package's `Builder` type.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
# 0.3 to 0.4
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* The new `decode` function complements the longstanding `encode`
|
|
Packit |
9a2dfb |
function, and makes the API simpler.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* New examples make it easier to learn to use the package
|
|
Packit |
9a2dfb |
(https://github.com/bos/aeson/tree/master/examples).
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Generics support
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
`aeson`'s support for data-type generic programming makes it
|
|
Packit |
9a2dfb |
possible to use JSON encodings of most data types without writing
|
|
Packit |
9a2dfb |
any boilerplate instances.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
Thanks to Bas Van Dijk, `aeson` now supports the two major schemes
|
|
Packit |
9a2dfb |
for doing datatype-generic programming:
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* the modern mechanism, built into GHC itself
|
|
Packit |
9a2dfb |
(http://www.haskell.org/ghc/docs/latest/html/users_guide/generic-programming.html)
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* the older mechanism, based on SYB (aka "scrap your
|
|
Packit |
9a2dfb |
boilerplate")
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
The modern GHC-based generic mechanism is fast and terse: in fact,
|
|
Packit |
9a2dfb |
its performance is generally comparable in performance to
|
|
Packit |
9a2dfb |
hand-written and TH-derived `ToJSON` and `FromJSON` instances. To
|
|
Packit |
9a2dfb |
see how to use GHC generics, refer to `examples/Generic.hs`.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
The SYB-based generics support lives in `Data.Aeson.Generic` and is
|
|
Packit |
9a2dfb |
provided mainly for users of GHC older than 7.2. SYB is far slower
|
|
Packit |
9a2dfb |
(by about 10x) than the more modern generic mechanism. To see how
|
|
Packit |
9a2dfb |
to use SYB generics, refer to `examples/GenericSYB.hs`.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* We switched the intermediate representation of JSON objects from
|
|
Packit |
9a2dfb |
`Data.Map` to `Data.HashMap` which has improved type conversion
|
|
Packit |
9a2dfb |
performance.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Instances of `ToJSON` and `FromJSON` for tuples are between 45% and 70%
|
|
Packit |
9a2dfb |
faster than in 0.3.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
* Evaluation control
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
This version of aeson makes explicit the decoupling between
|
|
Packit |
9a2dfb |
*identifying* an element of a JSON document and *converting* it to
|
|
Packit |
9a2dfb |
Haskell. See the `Data.Aeson.Parser` documentation for details.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
The normal `aeson` `decode` function performs identification
|
|
Packit |
9a2dfb |
strictly, but defers conversion until needed. This can result in
|
|
Packit |
9a2dfb |
improved performance (e.g. if the results of some conversions are
|
|
Packit |
9a2dfb |
never needed), but at a cost in increased memory consumption.
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
The new `decode'` function performs identification and conversion
|
|
Packit |
9a2dfb |
immediately. This incurs an up-front cost in CPU cycles, but
|
|
Packit |
9a2dfb |
reduces reduce memory consumption.
|