Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lift-json extract json with 'type' field into a case class

I am trying to extract JSON into a case class using lift-json. Here is my case class:

case class Person(name: String, age: Int)

Here is the json

{ "name": "Some Name", "age": 24, type: "Student" }

How can I extract the type field into an instance Person?

json.extract[Person]
like image 605
Chas Lemley Avatar asked Sep 18 '11 15:09

Chas Lemley


1 Answers

Backticks allow you to use reserved names.

case class Person(name:String, age:Int, `type`:String)
like image 125
Erick Fleming Avatar answered Dec 18 '22 05:12

Erick Fleming