title: how to serialize a DataTable to json or xml
body: <p>i'm trying to serialize DataTable to Json or XML. is it possibly and how? any tutorials and ideas, please. </p>
  
  <p>For example a have a sql table: </p>
  
  <pre><code>CREATE TABLE [dbo].[dictTable](
      [keyValue] [int] IDENTITY(1,1) NOT NULL,
      [valueValue] [int] NULL,
   CONSTRAINT [Psd2Id] PRIMARY KEY CLUSTERED 
  (
      [keyValue] ASC
  )WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
  ) ON [PRIMARY]
  </code></pre>
  
  <p>C# code:</p>
  
  <pre><code>string connectionString =
            "server=localhost;database=dbd;uid=**;pwd=**";
  
              SqlConnection mySqlConnection = new SqlConnection(connectionString);
              string selectString =  "SELECT keyValue, valueValue FROM dicTable";
  
              SqlCommand mySqlCommand = mySqlConnection.CreateCommand();
  
              mySqlCommand.CommandText = selectString;
  
              SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter();
  
              mySqlDataAdapter.SelectCommand = mySqlCommand;
  
              DataSet myDataSet = new DataSet();
  
              mySqlConnection.Open();
  
              string dataTableName = "dictionary";
              mySqlDataAdapter.Fill(myDataSet, dataTableName);
  
              DataTable myDataTable = myDataSet.Tables[dataTableName];
              //now how to serialize it?
  </code></pre>