I am a newbie in Scalatra. I have a servlet with JacksonJsonSupport which serves REST endpoint with list of objects.
class OperationsController extends MyappStack with JacksonJsonSupport {
before() {
contentType = formats("json")
}
get("/") {
Data.operations
}
}
The Operation
is implemented by either Adding
or Removing
case classes.
How do I add to the GET /
response the specific class to the value? I would like to get as a response:
[
{
"operation": "Adding",
"value": 100
}
]
Instead of
[
{
"value": 100
}
]
Where Adding
is a class that extends Operation
.