title: How to convert nested JSON to map object in scala
body: <p>I have the following JSON objects:</p>
  
  <pre><code>{
      "user_id": "123",
      "data": {
          "city": "New York"
      },
      "timestamp": "1563188698.31",
      "session_id": "6a793439-6535-4162-b333-647a6761636b"
  }
  {
      "user_id": "123",
      "data": {
          "name": "some_name",
          "age": "23",
          "occupation": "teacher"
      },
      "timestamp": "1563188698.31",
      "session_id": "6a793439-6535-4162-b333-647a6761636b"
  }
  </code></pre>
  
  <p>I'm using <code>val df = sqlContext.read.json("json")</code> to read the file to dataframe</p>
  
  <p>Which combines all data attributes into data struct like so:</p>
  
  <pre><code>root
   |-- data: struct (nullable = true)
   |    |-- age: string (nullable = true)
   |    |-- city: string (nullable = true)
   |    |-- name: string (nullable = true)
   |    |-- occupation: string (nullable = true)
   |-- session_id: string (nullable = true)
   |-- timestamp: string (nullable = true)
   |-- user_id: string (nullable = true)
  </code></pre>
  
  <p>Is it possible to transform data field to MAP[String, String] Data type? And so it only has the same attributes as original json?</p>