新手莫入(看完官方文件+自行實驗 心得)
and, reduce
會忽略沒有定義JsPath的tuple
最终有寫Reads的tuple才會留下
同常用於你想把Json減肥,或是挑選你要的tuple
Reads[A] andThen Reads[A] 並沒有忽略任何tuple
通常用於修改Json的內容, 但是tuple沒有減少
官方說法(看攏沒,WTF)
(Reads[JsObject] and Reads[JsObject]) reduce
- It merges results of both
Reads[JsObject]
(JsObject ++ JsObject) - It also applies the same JSON to both
Reads[JsObject]
unlikeandThen
which injects the result of the first reads into second one.
andThen
- is just the composition of 2
Reads[A]
- first reads is applied and then result is piped to second reads
學習來源 Json transformers