We could build a json object just like this:
import java.time.Instant
import play.api.libs.json.Json
object Test extends App {
println(Json.obj("time" -> Instant.now()))
//Output: {"time":"2018-05-25T18:13:23.409Z"}
}
The signature of Json.obj() method is:
def obj(fields: (String, JsValueWrapper)*): JsObject
While the implicit method Json.toJsFieldJsValueWrapper
is not in scope, how is Instant.now()
converted to JsValueWrapper successfully ? Thanks in advance for your reply !