Skip to content

Support Scala case classes #1

Closed
@cowtowncoder

Description

@cowtowncoder

(copied from [http://jira.codehaus.org/browse/JACKSON-304] -- see details)

(by James Strachan, Greg Zoller)

It doesn't feel very dry doing Scala with Jackson...

@BeanInfo class Position {
@BeanProperty
var x: Double = _
@BeanProperty
var y: Double = _

override def toString = "Position(" + x + "," + y + ")"
}

when it would be much nicer to be able to do

case class Position(x: Double, y: Double)

The main issue is that this class is immutable and that (ii) there are no fields/setters to call when deserializing, just a constructor.

Though when serializing the fields can be used.

Unfortunately Scala doesn't yet seem to support an easy way to iterate through the product field names & constructor argument names AFAIK so until Scala offers more reflection help this might be tricky...

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions