I'm playing around with replacing Java with Scala in my Spring MVC application and so far everything works fine except for serialization of case case class in return body.
Controller looks like this:
@RestController
@RequestMapping(Array("/level"))
class GameMapController {
@Autowired
private val gameMapService: GameMapService = null
@RequestMapping(value = Array("/{levelNumber}"), method = Array(RequestMethod.GET))
def getGameMap(@PathVariable levelNumber: Int): ResponseEntity[GameMap] = {
new ResponseEntity[GameMap](gameMapService.getGameMap(levelNumber), HttpStatus.OK)
}
and case class to be returned in body looks like this:
@Document
case class GameMap(@Id id: String, levelNumber: Int, width: Int, height: Int)
I checked if GameMap object have any properties set but i still receive empty Json in response. What did I miss? Do I need to provide some custom deseralization for Scala class?
levelNumberand for that you are getting properGameMapfrom functiongameMapService.getGameMap()?