title: Convert all the columns of a spark dataframe into a json format and then include the json formatted data as a column in another/parent dataframe
body: <p>Converted dataframe(say child dataframe) into json using df.toJSON </p>
  
  <p>After json conversion the schema looks like this :</p>
  
  <pre><code>root
   |-- value: string (nullable = true)
  </code></pre>
  
  <p>I used the following suggestion to get child dataframe into the intermediate parent schema/dataframe:</p>
  
  <pre><code>scala&gt; parentDF.toJSON.select(struct($"value").as("data")).printSchema
  root
   |-- data: struct (nullable = false)
   |    |-- value: string (nullable = true)
  </code></pre>
  
  <p>Now I still need to build the parentDF schema further to make it look like:</p>
  
  <pre><code>root
   |-- id
   |-- version 
   |-- data: struct (nullable = false)
   |    |-- value: string (nullable = true)
  </code></pre>
  
  <p>Q1) How can I build the id column using the id from value(i.e value.id needs to be represented as id)</p>
  
  <p>Q2) I need to bring version from a different dataframe(say versionDF) where version is a constant(in all columns). Do I fetch one row from this versionDF to read value of version column and then populate it as literal in the parentDF ? </p>
  
  <p>please help with any code snippets on this. </p>