title: scala json parse and get a nested key and value
body: <p>I have a json like below, </p>
  
  <p>I have json like below I need to extract the value from them</p>
  
  <pre><code>{
      "filed1": "value1",
      "message": {
          "payload": [{
              "type": ["Extra","ID"],
               info": {
                  "value": 8
              }
          }, {
              "type": ["Free"],
              info": {
                  "value": 99
              }
          }, {
              "type": ["Actual"],
               info": {
                  "value": 100
              }
          }]
      },
      "code": "0000"
  }
  
  
  {
      "filed1": "value1",
      "message": {
          "payload": [{
              "type": ["Extra", "new"],
              "value": 9
          }]
      },
      "code": "0001"
  }
  </code></pre>
  
  <p>from the above  two types of json .</p>
  
  <p>If the input json has list of <strong>type</strong> keys then look for type field which has element <strong>Extra</strong> and get the value inside info </p>
  
  <p>If the input json has one <strong>type</strong> key  then check type field , if it has element <strong>Extra</strong> and get the direct va;ue</p>
  
  <p>I am trying like below for type but it fails for list of types json, i.e first json input </p>
  
  <pre><code>import org.json4s._
  import org.json4s.jackson.JsonMethods._
  import org.json4s.JsonDSL._
  
  val json = parse(myjsonString, true)
  val field = compact(render(json \\ "type"))
  
  val ok = field.contains("[\"Extra\"")
  
  if(ok == true){
  println("value " +  compact(render(json \\ "value")))
  }
  </code></pre>