Skip to content

Commit

Permalink
Fixes jsonExclude annotation for Scala 3 (#1054)
Browse files Browse the repository at this point in the history
  • Loading branch information
alxdm authored Mar 18, 2024
1 parent 2fbf863 commit ede8742
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions zio-json/shared/src/main/scala-3/zio/json/macros.scala
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,7 @@ object DeriveJsonEncoder extends Derivation[JsonEncoder] { self =>
val len = params.length

val names =
IArray.genericWrapArray(ctx
.params
IArray.genericWrapArray(params
.map { p =>
p.annotations.collectFirst {
case jsonField(name) => name
Expand Down
4 changes: 2 additions & 2 deletions zio-json/shared/src/test/scala/zio/json/EncoderSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ object EncoderSpec extends ZIOSpecDefault {
},
test("exclude fields") {
import exampleexcludefield._
assert(Person("Peter", 20).toJson)(equalTo("""{"name":"Peter"}"""))
assert(Person(7, "Peter", 20).toJson)(equalTo("""{"name":"Peter"}"""))
},
test("aliases") {
import exampleproducts._
Expand Down Expand Up @@ -465,7 +465,7 @@ object EncoderSpec extends ZIOSpecDefault {

object exampleexcludefield {

case class Person(name: String, @jsonExclude age: Int)
case class Person(@jsonExclude id: Long, name: String, @jsonExclude age: Int)

object Person {
implicit val encoder: JsonEncoder[Person] = DeriveJsonEncoder.gen[Person]
Expand Down

0 comments on commit ede8742

Please sign in to comment.