scala - JSON deserialization using reflection -


hi trying extract json using reflection

import net.liftweb.json._ case class bike(make: string, price: int) {    def this(price: int) = this("trek", price) }  val cls = class.forname("bike") val manifest = manifest.classtype(cls) val parseddata =net.liftweb.json.jsonparser.parse(json)  jsonparser.parse(""" {"price":350} """).extract[manifest] 

however getting error:

not found: type manifest   jsonparser.parse(""" {"price":350} """).extract[manifest]                                                    ^ 

although manifest type manifest

you can extract directly case class

val json = "the json";  val bike = parse(json).extract[bike]; 

json parsing done through reflection.

if class runtime construct, create typeinfo instance , pass extract method.


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -