title: How to get converted csv into json with fields and data format in reactjs
body: <p>I am trying to convert CSV to JSON using Papa Parse 5. Below Data that I have</p>
  <pre><code>Firstname,Lasname,City
  Foo,bar, Mumbai
  abc,def,Pune
  xyz,pqr, Bangalore 
  </code></pre>
  <p>Code</p>
  <pre><code>Papa.parse(file, {
        complete: (result) =&gt; {
         console.log('result.data:', result.data);
        }
  })
  </code></pre>
  <p>Here &quot;file&quot; is the one file I am importing from local. the data is in the above format,
  and  I want to get it converted into the bellow JSON format.</p>
  <pre><code>{
      &quot;fields&quot;: [&quot;Firstname&quot;, &quot;Lasname&quot;, &quot;],
      &quot;data&quot;: [
          [&quot;foo&quot;, &quot;bar&quot;, &quot;Mumbai&quot;],
          [&quot;abc&quot;, &quot;def&quot;, &quot;Pune&quot;],
          [&quot;xyz&quot;,&quot;pqr&quot;, &quot;Bangalore&quot;]
      ]
  }
  </code></pre>
  <p>reference code sandbox- <a href="https://codesandbox.io/s/9nchp" rel="nofollow noreferrer">https://codesandbox.io/s/9nchp</a>
  reference - <a href="https://www.papaparse.com/docs" rel="nofollow noreferrer">https://www.papaparse.com/docs</a>
  Please help me to convert</p>