2

I am trying to convert json string to case object, but unable to do so using liftjson. Below is the code for reference:

import net.liftweb.json._
//implicit val formats = DefaultFormats // Brings in default date formats etc.
case class Tmp(id: Int, name: String)

object Test extends App{
  def getJSONObj(json: String): Tmp = {
      implicit val formats = DefaultFormats
      return parse(json).extract[Tmp]     
  }
}
val x = Test.getJSONObj("""
    {
      "id":1
      ,"name":"sid"
     }
     """)

Above code is returning

Executing command, time = 1563787522994
Executing command, time = 1563787522994
Executing command, time = 1563787522994
Executing command, time = 1563787522994
Executing command, time = 1563787522994
Executing command, time = 1563787522994
...

0 Answers0