title: Extracting json in Scala
body: <p>I have the following data structure:</p>
  
  <pre><code>val jsonStr = """
       {
        "data1": {
          "field1": "data1",
          "field2": 1.0,
          "field3": true
        },
        "data211": {
          "field1": "data211",
          "field2": 4343.0,
          "field3": false
        },
        "data344": {
          "field1": "data344",
          "field2": 436778.51,
          "field3": true
        },
        "data41": {
          "field1": "data41",
          "field2": 14348.0,
          "field3": true
        }
      }
    """
  </code></pre>
  
  <p>I want extract it. Here is what I'm doing without any luck:</p>
  
  <pre><code>#1. 
  case class Fields(field1: String, field2: Double, field3: Boolean)
  json.extract[Map[String, Map[Fields, String]]]
  //org.json4s.package$MappingException: Do not know how to convert JBool(true) 
  //into class       java.lang.String
  
  #2.
  json.extract[Map[String, Map[String, Fields]]
  //java.lang.InternalError: Malformed class name
  
  
  #3.
  json.extract[Map[String, Map[String, Any]]]
  //org.json4s.package$MappingException: No information known about type
  
  #4.
  json.extract[Map[String, Map[String, String]]]
  //org.json4s.package$MappingException: Do not know 
  //how to convert JBool(true) into class java.lang.String
  </code></pre>
  
  <p>How do I do that then?</p>
  
  <p>P.S. -- actually, that's <a href="https://github.com/json4s/json4s" rel="nofollow">https://github.com/json4s/json4s</a> but it's doesn't really matter since <code>lift</code> has the same API regarding json extracting.</p>
  
  <p><strong>UPDATE</strong>: It probably will require to use transform method. How will I use it?</p>
  
  <pre><code>val json = parse(jsonStr) transform { 
    case //.... what should be here to catch JBool -- "field3"?
  }
  </code></pre>
  
  <p><strong>UPDATE2</strong>:</p>
  
  <pre><code>#5
  json.extract[Map[String, Map[String, JValue]]]
  // Works! but it's not what I'm looking for, I need to use a pure Java/Scala type
  </code></pre>