title: How to convert Spark dataframe output to json?
body: <p>I am reading file with CSV file with Spark SQL Context.</p>
  
  <p><strong>Code :</strong> </p>
  
  <pre><code>m.put("path", CSV_DIRECTORY+file.getOriginalFilename());
  m.put("inferSchema", "true"); // Automatically infer data types else string by default
  m.put("header", "true");      // Use first line of all files as header         
  m.put("delimiter", ";");
  
  DataFrame df = sqlContext.load("com.databricks.spark.csv",m);              
  df.printSchema();
  </code></pre>
  
  <p>Fetching Column names and Data type with <code>df.printSchema()</code></p>
  
  <p><strong>O/P :</strong> </p>
  
  <pre><code>|--id : integer (nullable = true)
  |-- ApplicationNo: string (nullable = true)
  |-- Applidate: timestamp(nullable = true)
  </code></pre>
  
  <p>What is the return type of the statement printSchema. How to convert the output in JSON format, How to convert data frame into JSON??</p>
  
  <p><strong>Desired O/P:</strong> </p>
  
  <pre><code>{"column":"id","datatype":"integer"}
  </code></pre>