Skip to content

Instantly share code, notes, and snippets.

@maciej
Created August 20, 2015 16:46
Show Gist options
  • Select an option

  • Save maciej/9c9ff1eb6bdea016a0e5 to your computer and use it in GitHub Desktop.

Select an option

Save maciej/9c9ff1eb6bdea016a0e5 to your computer and use it in GitHub Desktop.
import com.softwaremill.thegarden.lawn.base.StringExtensions._
trait SnakeCaseJsonProtocol extends DefaultJsonProtocol {
override protected def extractFieldNames(classTag: ClassTag[_]) = super.extractFieldNames(classTag).map {_.underscore}
override protected def fromField[T](value: JsValue, fieldName: String)(implicit reader: JsonReader[T]) =
super.fromField(value, fieldName.camelCase)(reader)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment