The scala compiler usually infers the return type of methods based on their implementations, but it has trouble inferring the type of recursive methods.
The message recursive method parse needs result type
is due to this shortcoming. Your def parse(content: String)
recurses by calling parse(content)
. This makes the method recursive (infinitely so, but I'm assuming you were planning on changing it later). In order for it to compile, you'll need to explicitly state the return type, e.g. def parse(content: String): Unit
.
I'm going to take a further guess and say that there is a parse
method being imported from either json4s
or JsonMethods
. This is being shadowed by your own parse
method due to it having the same method signature. If you actually want to call JsonMethods.parse
, then you'll need to actually say JsonMethods.parse
to clarify the ambiguity.