0

I am new to Scala and Spray. I have an input JSON that basically maps to these case classes. I have managed to get the json parsed and this the output I am seeing:

case class First(param1:Boolean,param2:List[Parameter])
case class Parameter(name:String,age:Int)

val jsonCollection = input.convertTo[First]
val first=jsonCollection.map(x=>println(x.sql))

returns me this value

Vector(List(First(true,"ram",32),First(true,"siv",22)))

I am not sure how to iterate and retrieve values for each of the list object.

jmattheis
  • 10,494
  • 11
  • 46
  • 58
Siva
  • 21
  • 6
  • are you saying you want to retrieve values of `Vector[List[First]]`? you can `first.foreach { firsts => firsts.foreach {elem => println(elem.parama1)}}` – prayagupa Aug 28 '17 at 19:22
  • Are you sure it returns this value? Because your `First` has only two arguments. – ideaboxer Aug 28 '17 at 19:23
  • Consider posting a code which runs here: https://scastie.scala-lang.org (you can add the `spray-json` library to the build) – ideaboxer Aug 28 '17 at 19:25
  • 1
    @prayagupd - That worked thanks a lot. You are right this is not the actual code I just wanted the logic. The return is only 2 values. – Siva Aug 28 '17 at 23:03
  • @Siva awesome, go ahead and answer your own question. its fun :) – prayagupa Aug 28 '17 at 23:23

0 Answers0