title: How to bind json data to gridview in asp.net c#?
body: <p>I wanted to display the data from <code>JSON</code> file to the <code>gridview</code>. I've managed to decode the <code>JSON</code> file and I was trying to bind with the <code>gridview</code>. </p>
  
  <p>However, an error pops out. </p>
  
  <blockquote>
    <p>The error is: Newtonsoft.Json.JsonSerializationException: 'Unexpected
    JSON token when reading DataTable. Expected StartArray, got
    StartObject. Path '', line 1, position 1</p>
  </blockquote>
  
  <p><strong>The <code>JSON</code> code:</strong></p>
  
  <pre><code>{
   "value":{
  
  "Status": 2,
      "AffectedSegments": [
        {
  
          "Line": "NEL",
          "Direction": "HarbourFront",
          "Stations": "NE9,NE8,NE7,NE6", 
        "MRTShuttleDirection": "HarbourFront"}
        ,
        {
          "Line": "EWL",
          "Direction": "Simei", 
       "Stations": "NE9,NE8,NE7,NE6", 
      "MRTShuttleDirection": "HarbourFront"}],
      "Message": [
        {
          "Content": "0901hrs : NEL "
          "CreatedDate": "2018-03-16 09:01:53"
        }
      ]
    }
  }
  </code></pre>
  
  <p><strong>The code:</strong></p>
  
  <pre><code>    public DataTable jsonDataDiplay()
      {
          StreamReader sr = new StreamReader(Server.MapPath("TrainServiceAlerts.json"));
          string json = sr.ReadToEnd();
          var table = JsonConvert.DeserializeObject&lt;DataTable&gt;(json);
          //DataSet ds = JsonConvert.DeserializeObject&lt;Wrapper&gt;(json).DataSet;
          return table;
      }
  </code></pre>
  
  <p><strong>The design page:</strong></p>
  
  <pre><code> &lt;asp:GridView ID="GridView2" runat="server"&gt;
       &lt;Columns&gt;
           &lt;asp:BoundField DataField="Line" HeaderText="Line" /&gt;
           &lt;asp:BoundField DataField="Direction" HeaderText="Direction" /&gt;
            &lt;asp:BoundField DataField="Stations" HeaderText="Stations" /&gt;
            &lt;asp:BoundField DataField="MRTShuttleDirection" HeaderText="MRTShuttleDirection" /&gt;
  
  
       &lt;/Columns&gt;
   &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>I'm not sure how to solve the <strong>error</strong>. Please, help me and advise me! i have added " besides NE. It was there from the start in my json file just tht i didnt copy correctly here. </p>
  
  <p>Thank you in advance!</p>