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

风流意气都作罢 提交于 2019-12-05 15:11:55

问题


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]

回答1:


Backticks allow you to use reserved names.

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


来源:https://stackoverflow.com/questions/7462493/lift-json-extract-json-with-type-field-into-a-case-class

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!