From ede8742a66c4e8b7fa12a164bc9dc5fddbe7af8c Mon Sep 17 00:00:00 2001 From: Alex Demidov Date: Mon, 18 Mar 2024 23:45:42 +0700 Subject: [PATCH] Fixes jsonExclude annotation for Scala 3 (#1054) --- zio-json/shared/src/main/scala-3/zio/json/macros.scala | 3 +-- zio-json/shared/src/test/scala/zio/json/EncoderSpec.scala | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/zio-json/shared/src/main/scala-3/zio/json/macros.scala b/zio-json/shared/src/main/scala-3/zio/json/macros.scala index 31012a6ba..134711172 100644 --- a/zio-json/shared/src/main/scala-3/zio/json/macros.scala +++ b/zio-json/shared/src/main/scala-3/zio/json/macros.scala @@ -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 diff --git a/zio-json/shared/src/test/scala/zio/json/EncoderSpec.scala b/zio-json/shared/src/test/scala/zio/json/EncoderSpec.scala index 92c8fab59..77bf941ab 100644 --- a/zio-json/shared/src/test/scala/zio/json/EncoderSpec.scala +++ b/zio-json/shared/src/test/scala/zio/json/EncoderSpec.scala @@ -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._ @@ -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]