3

I'm trying to use json4s in a worksheet to try it out, I want simply to extract a json to some case class:

import org.json4s.native.JsonMethods
import org.json4s.{DefaultFormats, Extraction, JValue}

case class Person(name: String, age: Int)
val json = """{"name":"joe","age":15}"""

JsonMethods.parse(json).extract[Person]
Andrey Nikolov
  • 12,967
  • 3
  • 20
  • 32
Joe
  • 2,543
  • 3
  • 25
  • 49

1 Answers1

6

You forgot the implicit val jsonDefaultFormats = DefaultFormats right after your imports.

John K
  • 1,285
  • 6
  • 18