I can't find an explanation in the Play Framework docs. I found this question but now I can't see why will I use Format[A] at all.
Asked
Active
Viewed 495 times
-1
-
1`OFormat` will only read/write JSON objects, but maybe you have some types that you want to read/write as JSON string/int/Boolean.. – Gaël J Jan 23 '22 at 17:24
-
Can you give an example please? – idan ahal Jan 27 '22 at 11:21
-
1imagine a `case class Wrapper(str: String)` that you want to serialize as a plain JSON string `"..."` but not as `{str: ""}` – Gaël J Jan 27 '22 at 15:43
1 Answers
0
As Gaël mentioned:
OFormat
will only read/write JSON objects, but maybe you have some types that you want to read/write as JSON string/int/Boolean.
OFormat/OWrite returns a JsObject while Format/Write returns JsValue. You can do more with JsObject because it is a subclass of JsValue that represents a JSON object. JsValue can be a string, numeric, object or array.

idan ahal
- 707
- 8
- 21