-
-
Notifications
You must be signed in to change notification settings - Fork 143
forValueNulls Introduced in Jackson 2.9 Ignored #356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
There is a problem with the JsonSetter annotation and CreatorProperties (constructor parameters). public final Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOException
{
if (p.hasToken(JsonToken.VALUE_NULL)) {
return _nullProvider.getNullValue(ctxt);
}
if (_valueTypeDeserializer != null) {
return _valueDeserializer.deserializeWithType(p, ctxt, _valueTypeDeserializer);
}
return _valueDeserializer.deserialize(p, ctxt);
} this is the invocation stack
As you can see, when you have explicit I think it is kind of OK if those checks would be done somewhere later, but it does not seem to be the case (not sure, since not so much familiar with jackson internals) Don't know how to deal with it, yet. case class Issue87WorkAroundMapping @JsonCreator(mode = JsonCreator.Mode.DISABLED) (
id: String, vals: Map[String, String]) {
@JsonCreator
private def this(id: String) = this(id, Map.empty)
}
val nullMap: String = """{ "id":"MapID", "vals": null }"""
val mapper = new ObjectMapper with ScalaObjectMapper {
registerModule(DefaultScalaModule)
setDefaultSetterInfo(JsonSetter.Value.forValueNulls(Nulls.FAIL))
}
val mapping = mapper.readValue[Issue87WorkAroundMapping](nullMap) |
I've also encountered this problem. I find it not scala like, if you have options, then nulls should be forbidden on deserialization. |
I agree with @toefel18. The bug is not in scala module, but in databind. |
Most probably FasterXML/jackson-databind#2024 |
closed due to FasterXML/jackson-databind#2024 - reopen if you think the issue is still there |
Given this case class:
case class Value( @JsonSetter(nulls=Nulls.FAIL) offers: Map[String, Offer] = Map.empty[String, Offer] )
and this JSON:
{ "offers": null }
There is no failure on deserialization. I have also tried setting the value globally on
ObjectMapper
:objectMapper.setDefaultSetterInfo(JsonSetter.Value.forValueNulls(Nulls.FAIL))
This doesn't work either.
Am I doing something wrong? Or is this a bug?
Thanks.
The text was updated successfully, but these errors were encountered: