import net.liftweb.json._
import net.liftweb.json.JsonAST._
import net.liftweb.json.Extraction._
import net.liftweb.json.Printer._
implicit val formats = net.liftweb.json.DefaultFormats
val jV = JArray(List(JInt(10),JString("ahem"),JBool(false)))
I am dealing with a situation of mixed types and attempting to convert Jv to a List[Strings] using
jV.extract[List[String]]
The extraction does not work.
Can someone tell me how should I go about doing this
Lift JSON doesn't have a conversion between Strings and JBools defined in the serialisers.
Does the List inside of the Array always have the same shape? If so, then you can do something like:
If that won't work for you as there isn't a uniform shape but you still just want a list of Strings, then you can transform the JBools into JStrings before trying to do the extraction:
In general though, I'd encourage you think about why you are discarding the type information here. Quite a lot of Scala's power comes from it's type system so it's better to use it than to lose it by string-typing things here.