title: conversion from json to csv
body: <p>I needed to convert my json to csv format. I downloaded newtonsoft.json dll from <a href="http://json.codeplex.com/releases/view/74287" rel="nofollow">this link</a>. My code looks like this</p>
  
  <pre><code>using System.IO;
  using System;
  using System.Data;
  using Newtonsoft.Json;
  class Program
  {
      static void Main()
      {
          // Read in every line in the file.
          string text = System.IO.File.ReadAllText("input.txt");
          XmlNode xml = JSON.DeserializeXmlNode("{records:{record:" + text + "}}"); 
          XmlDocument xmldoc = new XmlDocument();
          xmldoc.LoadXml(xml.InnerXml); 
          var xmlReader = new XmlNodeReader(xmldoc);
          DataSet dataSet = new DataSet();
          dataSet.ReadXml(xmlReader);
          var csv = dataSet.Tables[0].getCSV(",");
      }
      public static string getCSV(this DataTable table,string delimitor)
      {
          var result = new StringBuilder();
          for (int i = 0; i &lt; table.Columns.Count; i++)
          {
              result.Append(table.Columns[i].ColumnName);
              result.Append(i == table.Columns.Count - 1 ? "\n" : delimitor);
          }
          foreach (DataRow row in table.Rows)
          {
              for (int i = 0; i &lt; table.Columns.Count; i++)
              {
                  result.Append(row[i].ToString());
                  result.Append(i == table.Columns.Count - 1 ? "\n" : delimitor);
              }
          }
          return result.ToString().TrimEnd(new char[] { '\r', '\n' });
          //return result.ToString();
      }
  }
  </code></pre>
  
  <p>am i missing something here? Iam not able to deserialise the json object itself</p>