The Serializer
utility class converts a Scala data structure to JsonLogic-Typed data.
Configure theSerializer
class with the SerializerConf
object. This object defines how Scala data structures map to the JsonLogic-Typed format. If no custom object is provided, the default SerializerConf
is used .
Serializing examples:
- With default
Serializer
andSerializerConf
import play.api.libs.json.Json
val jsonLogicCore: JsonLogicCore = ...
val jsonString = Json.stringify(Json.toJson(jsonLogicCore))
- With custom
SerializerConf
import play.api.libs.json.Json
val jsonLogicCore: JsonLogicCore = ...
implicit val serializerConf = SerializerConf.createConf(...)
implicit val serializer = new Serializer()
val jsonString = serializer.serialize(jsonLogicCore)
- With custom
Serializer
import play.api.libs.json.Json
val jsonLogicCore: JsonLogicCore = ...
implicit val serializer = new Serializer() {
...
override def serialize(jsonLogic: JsonLogicCore): (JsValue, JsValue) = {...}
}
val jsonString = serializer.serialize(jsonLogicCore)