Skip to content

Instantly share code, notes, and snippets.

@levinotik
Created July 8, 2013 21:19
Show Gist options
  • Select an option

  • Save levinotik/5952596 to your computer and use it in GitHub Desktop.

Select an option

Save levinotik/5952596 to your computer and use it in GitHub Desktop.
case class GoogleApiResult(results: Results, status: String)
case class AddressComponent(long_name: String, short_name: String, types: List[String])
case class Location(lat: Double, lng: Double)
case class Bounds(northeast: Location, southwest:Location)
case class Viewport(northeast: Location, southwest:Location)
case class Geometry(bounds: Bounds, location: Location, locationType: String, viewport: Viewport)
case class Results(address_components: List[AddressComponent], formatted_address:String, geometry: Geometry, types: List[String])
import SprayJsonSupport._
object MyJsonProtocol extends DefaultJsonProtocol {
implicit val locationFormat = jsonFormat2(Location)
implicit val boundsFormat = jsonFormat2(Bounds)
implicit val addressComponentsFormat = jsonFormat3(AddressComponent)
implicit val viewportFormat = jsonFormat2(Viewport)
implicit val geometryFormat = jsonFormat4(Geometry)
implicit val resultsFormat = jsonFormat4(Results)
implicit val googleApiResult = jsonFormat2(GoogleApiResult)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment