假设您要像这样导入库:
import play.api.libs.json.{__, Writes }
双下划线有什么作用?
JsPath是用于创建读取/写入的核心构建块。JsPath表示数据在JsValue结构中的位置。您可以使用JsPath对象(根路径)通过类似于遍历JsValue的语法来定义JsPath子实例:
import play.api.libs.json._
val json = { ... }
// Simple path
val latPath = JsPath \ "location" \ "lat"
// Recursive path
val namesPath = JsPath \\ "name"
// Indexed path
val firstResidentPath = (JsPath \ "residents")(0)
play.api.libs.json包为JsPath定义了一个别名:__(双下划线)。如果您愿意,可以使用它:
val longPath = __ \“位置” \“长”
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句