-
-
Notifications
You must be signed in to change notification settings - Fork 143
Open
Description
Can be reproduced with the following test case:
diff --git a/src/test/scala/com/fasterxml/jackson/module/scala/ser/CaseClassSerializerTest.scala b/src/test/scala/com/fasterxml/jackson/module/scala/ser/CaseClassSerializerTest.scala
index 6dc1d665..33dddf06 100644
--- a/src/test/scala/com/fasterxml/jackson/module/scala/ser/CaseClassSerializerTest.scala
+++ b/src/test/scala/com/fasterxml/jackson/module/scala/ser/CaseClassSerializerTest.scala
@@ -2,6 +2,9 @@ package com.fasterxml.jackson.module.scala.ser
import com.fasterxml.jackson.annotation.JsonProperty.Access
import com.fasterxml.jackson.annotation._
+import com.fasterxml.jackson.databind.MapperFeature
import com.fasterxml.jackson.databind.{ObjectMapper, PropertyNamingStrategies}
import com.fasterxml.jackson.module.scala.DefaultScalaModule
@@ -62,6 +65,8 @@ case class PrivateDefaultFields(
case class ClassWithUnitField(field: Unit, intField: Int)
case class ClassWithOnlyUnitField(field: Unit)
+case class ClassWithUnorderedFields(f3: Int = 3, f2: Int = 2, f0: Int = 0, f1: Int = 1)
+
class CaseClassSerializerTest extends SerializerTest {
case class NestedClass(field: String)
@@ -207,4 +212,11 @@ class CaseClassSerializerTest extends SerializerTest {
serialize(GeneratedDefaultArgumentClass()) shouldEqual "{}"
}
+ it should "sort properties of the case class" in {
+ val mapper = newBuilder
+ .configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true)
+ .build()
+ serialize(ClassWithUnorderedFields(), mapper) shouldEqual """{"f0":0,"f1":1,"f2":2,"f3":3}"""
+ }
+
}This test cases passes with 2.19.2 and fails with 2.20.0. I thought it might be related to FasterXML/jackson-databind#3900, but disabling MapperFeature.SORT_CREATOR_PROPERTIES_FIRST does not resolve the issue.
rhuddleston
Metadata
Metadata
Assignees
Labels
No labels