This page is no longer maintained — Please continue to the home page at www.scala-lang.org

case class 22 fields limit

2 replies
Christopher Sch...
Joined: 2010-08-30,
User offline. Last seen 42 years 45 weeks ago.
Many frameworks are using case casses as data holder classes for JSON or SQL tables.I have such a JSON object with more than 30 fields and I found out that there is a hard limit to 22 fields for case classes. To spilt it up into 2 (or more) case classes would not be very convenient.
I found that there where already some discussions about that: f.e. http://www.scala-lang.org/node/7910
Can someone tell the actual status of this?
Or are there some ideas to "overwrite" or work around that limit?

Cheers
--
Christophertwitter: @fakodblog: http://blog.fakod.eu
Peter 2
Joined: 2011-02-16,
User offline. Last seen 42 years 45 weeks ago.
Re: case class 22 fields limit

Hi Christopher,

what about a non-case class with an appropriate unapply in its
companion object, instead? I did the same for other reasons in the
context of lift-json.

Peter

Lars Hupel
Joined: 2010-06-23,
User offline. Last seen 44 weeks 4 days ago.
Re: case class 22 fields limit

The best "workaround" for that is to use heterogeneous lists as
described in [1]. Try to read the other posts of the series on HLists, too.

[1]

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland