Skip to content

gcnyin/play-jsoniter

Repository files navigation

play-jsoniter

Usage

import play.api.mvc.{Action, BaseController, ControllerComponents}
import javax.inject.{Inject, Singleton}
import scala.concurrent.ExecutionContext
import play.api.libs.jsoniter.Jsoniter

@Singleton
class UserController @Inject()(val controllerComponents: ControllerComponents)
                              (implicit executionContext: ExecutionContext)
  extends BaseController with Jsoniter {

  final case class User(id: Int, username: String)

  object User {
    import com.github.plokhotnyuk.jsoniter_scala.core._
    import com.github.plokhotnyuk.jsoniter_scala.macros._

    implicit val jsoniterCodec: JsonValueCodec[User] = JsonCodecMaker.make
  }

  def create(): Action[User] = Action(jsoniter.json[User]) { request =>
    Ok
  }
}

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages