At a glance I believe Strings go through an optimized path and bypass
formatter handling. To do this, you'll probably need to transform the JSON
before trying to extract it:
val parsed = parse(d2)
val nulledEmptyStrings =
parsed transform {
case JString("") => JNull
}
val extracted = nulledEmptyStrings.extract[Dummy.Person]
This of course isn't field-targeted. You can target a particular field:
val parsed = parse(d2)
val nulledEmptyStrings =
parsed transformField {
case JField("job", JString("")) => JField("job", JNull)
}
val extracted = nulledEmptyStrings.extract[Dummy.Person]
I don't think you can intercept this with a custom serializer, but I might be
wrong, in which case hopefully someone will step in to correct me :)
Thanks,
Antonio