playframework/Play20 — pull request #662 by mandubian (2013-01-09 15:02:35+00:00)
Title: Json refact : read/write/formatOpt deprecated -> read/write/formatNullable

To prevent confusion with JsValue.asOpt and provide a consistent behavior when managing Option with Json, we have decided to refactor a bit:

- `read/write/formatOpt` which didn't manage `null` value and had confusing name are now deprecated
- `read/write/formatNullable` now are the new preferred `Reads/Writes/Format` for optional or nullable fields:
- `(__ \ 'field1 \ 'field2).readNullable`:
- reads missing or `JsNull` (null) field to `None`
- if `JsPath` is not fully trackable till last node, it sends a `JsError("missing-path")`

- `(__ \ 'field1 \ 'field2).writeNullable` simply omits fields when having value None

- `ConstraintWrites/Reads/Format.nullable(implicit Reads[A])` have been renamed to optionWithNull to prevent confusion with jsPath.readNullable:
- `ConstraintWrites.optionWithNull` : writes `JsNull` for `None` (which is different from writeNullable)
- `ConstraintReads.optionWithNull` : reads `None` from `JsNull`

I've also added 2 features:

- JsPath recursive \\ now runs through JsArray too
- `JsValue.transform[A <: JsValue](Reads[A])` is a restricted shortcut for validate[A] to be used with Json transformers because people are disturbed to have to call validate when transforming JSON.

`json.transform((__\'toto).json.pick) == json.validate((__\'toto).json.pick)`