The compiler error you posted comes from this location in json4s code . The write function that you call accepts an implicit JSON Writer , so the method can accept arbitrary types. It got during compilation because the implicit arguments were compiled the same as the explicit ones - as if you had:
def f(a: Int, b: Int) = a + b f(5)
I'm having problems with exactly which write method you are calling here - the json4s library is quite large and things are overloaded. Can you insert the declared write method that you use? It almost certainly has this signature:
def write[T](value: T)(implicit writer: Writer[T]): JValue
If it looks like this, try including the implicit writer option in your method like this:
object JsonHelper { def json2Object[O](input: String)(implicit reader: Reader[O]) : O = { parse(json4s.string2JsonInput(input)).asInstanceOf[O] } def object2Json[O](input: O)(implicit writer: Writer[O]) : String = { write(input).toString } }
source share