Is it possible to serialize object of below class using Json4s or lift or any other library?
class User(uId: Int) extends Serializable {
var id: Int = uId
var active: Boolean = false
var numTweets: Int = 0
var followers: ArrayBuffer[Int] = null
var following: ArrayBuffer[Int] = null
var userTimeline: Queue[String] = null
var homeTimeline: Queue[String] = null
var userTimelineSize: Int = 0
var homeTimelineSize: Int = 0
//var notifications: Queue[String] = null
var mentions: Queue[String] = null
var directMessages: Queue[String] = null
}
You can use Json4s for this purpose (with help of
FieldSerializer
), below is the code to get started with serialization of theUser
object:Also, in your non case class anything which is missing from the JSON needs to be an Option.
Another method would be to go for Genson: