title: Flattening Rows in Spark
body: <p>I am doing some testing for spark using scala. We usually read json files which needs to be manipulated like the following example:</p>
  
  <p>test.json:</p>
  
  <pre><code>{"a":1,"b":[2,3]}
  </code></pre>
  
  <pre class="lang-scala prettyprint-override"><code>val test = sqlContext.read.json("test.json")
  </code></pre>
  
  <p>How can I convert it to the following format:</p>
  
  <pre><code>{"a":1,"b":2}
  {"a":1,"b":3}
  </code></pre>