title: Save DF with JSON string as JSON without escape characters with Apache Spark
body: <p>I have a dataframe which contains some column and json string:</p>
  <pre><code>val df = Seq (
   (0, &quot;&quot;&quot;{​&quot;device_id&quot;: 0, &quot;device_type&quot;: &quot;sensor-ipad&quot;, &quot;ip&quot;: &quot;68.161.225.1&quot;, &quot;cca3&quot;: &quot;USA&quot;, &quot;cn&quot;: &quot;United States&quot;, &quot;temp&quot;: 25, &quot;signal&quot;: 23, &quot;battery_level&quot;: 8, &quot;c02_level&quot;: 917, &quot;timestamp&quot; :1475600496 }​&quot;&quot;&quot;),
   (1, &quot;&quot;&quot;{​&quot;device_id&quot;: 1, &quot;device_type&quot;: &quot;sensor-igauge&quot;, &quot;ip&quot;: &quot;213.161.254.1&quot;, &quot;cca3&quot;: &quot;NOR&quot;, &quot;cn&quot;: &quot;Norway&quot;, &quot;temp&quot;: 30, &quot;signal&quot;: 18, &quot;battery_level&quot;: 6, &quot;c02_level&quot;: 1413, &quot;timestamp&quot; :1475600498 }​&quot;&quot;&quot;)
  ).toDF(&quot;id&quot;, &quot;json&quot;)
  </code></pre>
  <p>Which I want to save as json - without a nested json string in it but a 'raw' one instead.
  When I
  <code>df.write.json(&quot;path&quot;)</code>
  It saves my json column as string:</p>
  <pre><code>{&quot;id&quot;:0,&quot;json&quot;:&quot;{​\&quot;device_id\&quot;: 0, \&quot;device_type\&quot;: \&quot;sensor-ipad\&quot;, \&quot;ip\&quot;: \&quot;68.161.225.1\&quot;, \&quot;cca3\&quot;: \&quot;USA\&quot;, \&quot;cn\&quot;: \&quot;United States\&quot;, \&quot;temp\&quot;: 25, \&quot;signal\&quot;: 23, \&quot;battery_level\&quot;: 8, \&quot;c02_level\&quot;: 917, \&quot;timestamp\&quot; :1475600496 }​&quot;}
  </code></pre>
  <p>And what I need is:</p>
  <pre><code>{&quot;id&quot;: 0,&quot;json&quot;: {&quot;device_id&quot;: 0,&quot;device_type&quot;: &quot;sensor-ipad&quot;,&quot;ip&quot;: &quot;68.161.225.1&quot;,&quot;cca3&quot;: &quot;USA&quot;,&quot;cn&quot;: &quot;United States&quot;,&quot;temp&quot;: 25,&quot;signal&quot;: 23,&quot;battery_level&quot;: 8,&quot;c02_level&quot;: 917,&quot;timestamp&quot;: 1475600496}}
  </code></pre>
  <p>How can I achieve it? Please not that the structure of json could be different for each row, it can contain additional fields.</p>