json - HowTo enforce Play framework 2.4.x to serialize field with empty list -
i'm using scala play! 2.4.x , trying searialize case class:
case class myevent( id: string, parentid: option[parentref] = none, stepstatus: string = "undefined", artifacts:seq[string] = seq.empty, events:seq[string] = seq.empty )
the problem serialized json doesn't contain fields artifacts , events since default values empty sequences. receiver expects field names if empty. have force json serializer add "artifacts": [], "events":[]
what right way without writing whole formatter manually? have dozens fields.
so, 2.4.x works way:
case class myevent( id: string, parentid: option[parentref] = none, stepstatus: string = "undefined", artifacts:seq[string] = seq(), events:seq[string] = seq() )
seq() forces play json generate "events": [] fine me. find play-json stuff bit on engineered. :( miss google gson java past :) dead simple , works.
Comments
Post a Comment