2

Say I have a case case such as:

case class Stuff(name:String,stuffs:List[String] = List.empty)

How can I prevent jackson from deserialization the json

{
  "name":"Alex" 
}

With

Stuff("Alex",null)

I would prefer it to be constructed with

Stuff("Alex")

Is there a way to configure Jackson to work in this way? or do I have to define other constructors. e.g. with missing stuffs

aclowkay
  • 3,577
  • 5
  • 35
  • 66

1 Answers1

0

The same problem.

  1. You can write your own de-serializer
  2. What version are you using: java or scala (json4s)? If java you may try the second one
  3. As ugly solution you may wrap stuffs in option, as I know jackson handles options fine.
Sergio Tulentsev
  • 226,338
  • 43
  • 373
  • 367
Igor Yudnikov
  • 434
  • 1
  • 6
  • 14