I have parsed a response from an HTTP API using the parse() function from the Lift library
val resultObj = parse(response)
val dps = resultObj \\ "dps"
println("dps are "+dps)
I have something like this now :
JObject(List(JField(1410418778,JDouble(0.0)), JField(1410418947,JDouble(0.0)), JField(1410419163,JDouble(0.0)), JField(1410419314,JDouble(0.0)))
I want to retreive "1410418778" and the corresponding double value i.e 0.0 out of this.
I have tried the following :
dps.children.foreach(element=>{
println("element "+element+ "and its extract is Double "+
element.extract[Double]+" and its String extract is "+
element.extract[String])
val child = element.children
println("element child "+child)
})
output ::
element JField(1410420437,JDouble(1.0))and its extract is Double 1.0 and its String extract is 1.0
element child List(JDouble(1.0))
Hoever both extract[String] and extract[Double] are giving only the value in the JDouble() field. Hw do i extract the string timestamp out of this too? Thanks in advance!
Was unnecessarily complicating the answer. It is as direct as this :
val resultMap : Map[String , Any] = dps.asInstanceOf[JObject].values
println(resultMap)
Got from here :