Skip to content

Instantly share code, notes, and snippets.

@ubourdon
Last active November 12, 2021 08:21
Show Gist options
  • Save ubourdon/0d9bb30990c7ebee2427b0f9ab16f070 to your computer and use it in GitHub Desktop.
Save ubourdon/0d9bb30990c7ebee2427b0f9ab16f070 to your computer and use it in GitHub Desktop.
example sealed trait zio json
sealed trait UserFilterRight
object UserFilterRight {
case object FilterByMyUid extends UserFilterRight
case class FilterByUser(users: Seq[SafeUUID]) extends UserFilterRight
case object AllInCabinet extends UserFilterRight
case object CanSeeNothing extends UserFilterRight
}
/**
I need to encode and deocde with discriminator e.g
{ "rightType": "FilterByUser"
, "users": [ "12345" ]
}
BUT without using @jsonDiscriminator annotation
*/
@wadouk
Copy link

wadouk commented Nov 12, 2021

Or with a DTO ?

case class UserFilterRightDTO(rightFilter: String, users: Option[Seq[String]])

a codec on it
a pattern matching on results to encode or decode to UserFilterRight ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment