2

I am trying to parse a class and for some reason Jackson (actually Jerkson interface in Scala) is taking a dump. I am guessing it might have something to do with BoardOpen being a subclass of a MessageEvent class:

class BoardOpen(

  override val channel: String

) extends MessageEvent(channel)

and

class MessageEvent( val channel: String = "/" )

The full error:

The error com.codahale.jerkson.ParsingException: No suitable constructor found
for type [simple type, class engine.event.BoardOpen]: can not instantiate from J
SON object (need to add/enable type information?)
 at [Source: java.io.StringReader@4004c5b3; line: 1, column: 2]
        at com.codahale.jerkson.ParsingException$.apply(ParsingException.scala:17)
        at com.codahale.jerkson.Parser$class.parse(Parser.scala:86)
        at com.codahale.jerkson.Json$.parse(Json.scala:6)
        at com.codahale.jerkson.Parser$class.parse(Parser.scala:14)
        at com.codahale.jerkson.Json$.parse(Json.scala:6)
        at controllers.socket.MessageParser$.matchMsg(MessageParser.scala:59)
        at controllers.socket.MessageParser$.parseRawMessage(MessageParser.scala:90)
        at controllers.socket.MessageParser$.readStringMsg(MessageParser.scala:42)

And here's what's going on when I go to parse the data:

msgCase match {
       case "BoardOpen"            => parse[BoardOpen](msgData)

and the JSON looks like:

{"channel":"/board"}

Any ideas why it is failing? Thanks.

Update:

Because there's only the channel property to worry about, I thought I'd see what would happen if I changed parsing to parse[MessageEvent](msgData) and strangely it spit the same error:

The error com.codahale.jerkson.ParsingException: No suitable constructor found
for type [simple type, class com.alloyengine.powder.MessageEvent]: can not insta
ntiate from JSON object (need to add/enable type information?)
 at [Source: java.io.StringReader@34fd2520; line: 1, column: 2]
4

0 に答える 0