JsPath is the main building block for creating Reads / Writes. JsPath represents the location of data in a JsValue structure. You can use the JsPath object (root path) to define a child JsPath instance using syntax similar to a JsValue traversal:
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)
The play.api.libs.json package defines an alias for JsPath: __ (double underscore). You can use this if you want:
val longPath = __ \ "location" \ "long"
source share