scalaplayframeworkplay-json

Play Framework, Format[A] vs OFormat[A]


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.


Solution

  • 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.