【问题标题】:Passing an implicit to a playframework JSON Reads将隐式传递给 playframework JSON 读取
【发布时间】:2013-06-06 09:14:31
【问题描述】:

我想知道将隐式传递给 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 特征不匹配

【问题讨论】:

    标签: json playframework-2.0 implicit


    【解决方案1】:

    你不能改变 Reads[T],很明显。 我会简单地创建自己的读取函数,例如?

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-02
      • 2014-01-21
      • 1970-01-01
      • 2018-06-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多