Created
July 1, 2016 12:30
-
-
Save justgook/cbed74ea48777f82291065c04c040fa9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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