title: Convert CSV to JSON and JSON to CSV using PowerShell
body: <p>I have a CSV file that I am trying to convert to JSON using PowerShell.</p>
  
  <p>The CSV file contains the following data.</p>
  
  <p><strong>web_url.csv</strong></p>
  
  <pre><code>wikipedia,https://en.wikipedia.org/wiki/%s
  wolframalpha,http://www.wolframalpha.com/input/?i=%s
  drive,http://www.drive.google.com/
  </code></pre>
  
  <p>I would like to convert to json in the following format. Similarly how do you convert this json back to original csv in the format shown above?</p>
  
  <p><strong>web_url.json</strong></p>
  
  <pre><code>{
      "wikipedia": "https://en.wikipedia.org/wiki/%s",
      "wolframalpha": "http://www.wolframalpha.com/input/?i=%s",
      "drive": "http://www.drive.google.com/"
  }
  </code></pre>
  
  <p>When I run the command,</p>
  
  <blockquote>
    <p>Get-Content -path web_url.csv | ConvertFrom-Csv -Delimiter ',' |
    ConvertTo-Json</p>
  </blockquote>
  
  <p>it returns the following output which is not what I want.</p>
  
  <pre><code>[
      {
          "wikipedia":  "wolframalpha",
          "https://en.wikipedia.org/wiki/%s":  "http://www.wolframalpha.com/input/?i=%s"
      },
      {
          "wikipedia":  "drive",
          "https://en.wikipedia.org/wiki/%s":  "http://www.drive.google.com/"
      }
  ]
  </code></pre>