繁体   English   中英

将隐式传递给playframework JSON读取

[英]Passing an implicit to a playframework JSON Reads

我想知道将隐式传递给Playframework Json Reader / Writer的最佳方法是什么

http://www.playframework.com/documentation/api/2.0/scala/play/api/libs/json/Reads.html

换句话说,我希望能够执行以下操作:

def reads(json: JsValue)(implicit configuration: TenantConfiguration): JsResult[User]

但是我无法这样做,因为Reads特质不匹配

很明显,您不能更改Reads [T]。 我只是创建自己的读取函数,例如?

def customReads[T](json:JsValue)(implicit reads: Reads[T], configuration: TenantConfiguration): JsResult[T] = ...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM