score:1

i solved this problem. i have case class request. i can get schema or not from request. i process this request as follows:

import upickle.default.{readwriter => rw, _}

case class request(id: long, name: string, schema: option[string])

implicit lazy val deserializer: reader[request] =
reader[ujson.obj].map[request](json => request(
    read[long](json("id")),
    read[string](json("name")),
    if (json.obj.contains("schema")) { option(read[string](json("schema"))) } else none
)

Related Query

More Query from same tag