File tree 1 file changed +16
-1
lines changed
src/test/scala/tools/jackson/module/scala/deser
1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 1
1
package tools .jackson .module .scala .deser
2
2
3
- import com .fasterxml .jackson .annotation .JsonProperty
3
+ import com .fasterxml .jackson .annotation .{ JsonProperty , JsonSetter , Nulls }
4
4
import tools .jackson .databind .annotation .JsonDeserialize
5
5
import tools .jackson .databind .exc .MismatchedInputException
6
6
import tools .jackson .databind .json .JsonMapper
@@ -69,6 +69,9 @@ object CaseClassDeserializerTest {
69
69
class NestedB (id : Int ) {
70
70
def x = id
71
71
}
72
+
73
+ case class ListHolder [T ](list : List [T ])
74
+ case class AnnotatedListHolder [T ](@ JsonSetter (nulls = Nulls .AS_EMPTY )list : List [T ])
72
75
}
73
76
74
77
class CaseClassDeserializerTest extends DeserializerTest {
@@ -195,4 +198,16 @@ class CaseClassDeserializerTest extends DeserializerTest {
195
198
val result = deserialize(input, classOf [ClassWithOnlyUnitField ])
196
199
result shouldEqual ClassWithOnlyUnitField (())
197
200
}
201
+
202
+ it should " support deserializing null input for list as empty list" ignore {
203
+ val input = """ {}"""
204
+ val result = deserialize(input, classOf [ListHolder [String ]])
205
+ result.list shouldBe null // ideally should be empty list, Scala users expect no nulls
206
+ }
207
+
208
+ it should " support deserializing null input for list as empty list (JsonSetter annotation)" in {
209
+ val input = """ {}"""
210
+ val result = deserialize(input, classOf [AnnotatedListHolder [String ]])
211
+ result.list shouldBe List .empty
212
+ }
198
213
}
You can’t perform that action at this time.
0 commit comments