Skip to content
Snippets Groups Projects
Commit 2f57242d authored by Tobias Ullerich's avatar Tobias Ullerich
Browse files

Improved json response handling, add own equals method for session

parent b5e6f91a
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,22 @@ import scala.util.Random
def getId: Int = id
def getAccount: Account = account
def canEqual(other: Any): Boolean = other.isInstanceOf[Session]
override def equals(other: Any): Boolean = other match {
case that: Session =>
(that canEqual this) &&
id == that.id &&
key == that.key
case _ => false
}
override def hashCode(): Int = {
val state = Seq(id, key)
state.map(_.hashCode()).foldLeft(0)((a, b) => 31 * a + b)
}
}
object Session {
......
......@@ -28,7 +28,7 @@ class SessionGet(accountDao: Dao[Account, Int]) extends Route {
jsonObj.addProperty("createDate", session.createDate.getTime)
array.add(jsonObj)
})
return array.toString
return array
}
}
......
package de.tobias.playpad.server.transformer
import com.google.gson.Gson
import com.google.gson.{Gson, JsonObject}
import spark.ResponseTransformer
/**
......@@ -11,6 +11,10 @@ class JsonTransformer extends ResponseTransformer {
val gson = new Gson()
override def render(o: scala.Any): String = {
if (!o.isInstanceOf[JsonObject]) {
gson.toJson(o)
} else {
o.toString
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment