Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/test/java/tools/jackson/module/scala/AnnotatedColor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package tools.jackson.module.scala;

import com.fasterxml.jackson.annotation.JsonProperty;

public enum AnnotatedColor {
@JsonProperty("red") RED
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import tools.jackson.core.JsonGenerator
import tools.jackson.databind.annotation.JsonSerialize
import tools.jackson.databind.json.JsonMapper
import tools.jackson.databind.{SerializationContext, ValueSerializer}
import tools.jackson.module.scala.{DefaultScalaModule, JacksonModule}
import tools.jackson.module.scala.{AnnotatedColor, DefaultScalaModule, JacksonModule}

import scala.annotation.meta.getter
import scala.beans.BeanProperty
Expand All @@ -20,7 +20,6 @@ class TupleKeySerializer extends ValueSerializer[Product] {
}
}


object MapSerializerTest {

class BeanieWeenie(@BeanProperty @JsonProperty("a") var a: Int,
Expand Down Expand Up @@ -105,4 +104,9 @@ class MapSerializerTest extends SerializerTest {
val wrapper = MapValueBaseWrapper(Map("Double" -> MapValueDouble(1.0), "String" -> MapValueString("word")))
serialize(wrapper) should be ("""{"map":{"Double":{"type":"MapValueDouble","value":1.0},"String":{"type":"MapValueString","value":"word"}}}""")
}

it should "support JsonProperty annotation on Java enum key" in {
val map = Map(AnnotatedColor.RED -> "redValue")
newMapper.writeValueAsString(map) shouldEqual """{"red":"redValue"}"""
}
}