Skip to content

Instantly share code, notes, and snippets.

@justgook
Created July 1, 2016 12:30
Show Gist options
  • Save justgook/cbed74ea48777f82291065c04c040fa9 to your computer and use it in GitHub Desktop.
Save justgook/cbed74ea48777f82291065c04c040fa9 to your computer and use it in GitHub Desktop.
package protocols
import play.api.libs.functional.syntax._
import play.api.libs.json.{Format, JsPath, Json}
/**
* Created by Roman Potashow on 30.06.2016.
*/
case class Settings(name: String, label: String, properties: List[Settings.Property])
object Settings {
case class Property(name: String, _type: String, label: String, defaultValue: String, enum: Option[String] = None)
object Property {
implicit val propertyFormat: Format[Property] = (
(JsPath \ "name").format[String] and
(JsPath \ "type").format[String] and //TODO change it to subclasses
(JsPath \ "label").format[String] and
(JsPath \ "defaultValue").format[String] and
(JsPath \ "enum").formatNullable[String]
) (Property.apply, unlift(Property.unapply))
}
implicit val settingsFormat = Json.format[Settings]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment