title: How to access sub-entities in JSON file?
body: <p>I have a json file look like this:</p>
  
  <pre><code>{
    "employeeDetails":{
      "name": "xxxx",
      "num":"415"
    },
    "work":[
      {
        "monthYear":"01/2007",
        "workdate":"1|2|3|....|31",
        "workhours":"8|8|8....|8"
      },
      {
        "monthYear":"02/2007",
        "workdate":"1|2|3|....|31",
        "workhours":"8|8|8....|8"
      }
    ]
  }
  </code></pre>
  
  <p>I have to get the workdate, workhours from this json data.</p>
  
  <p>I tried like this:</p>
  
  <pre><code>import org.apache.spark.{SparkConf, SparkContext}
  
  object JSON2 {
    def main (args: Array[String]) {
      val spark =
        SparkSession.builder()
          .appName("SQL-JSON")
          .master("local[4]")
          .getOrCreate()
  
      import spark.implicits._
  
      val employees = spark.read.json("sample.json")
      employees.printSchema()
      employees.select("employeeDetails").show()
    }
  }
  </code></pre>
  
  <p>I am getting exception like this:</p>
  
  <pre><code>Exception in thread "main" org.apache.spark.sql.AnalysisException: cannot resolve '`employeeDetails`' given input columns: [_corrupt_record];;
  'Project ['employeeDetails]
  +- Relation[_corrupt_record#0] json
  </code></pre>
  
  <p>I am new to Spark.</p>