title: ASP.NET Core C# Jquery Datatable Error: Unexpected token
body: <p>I want to fill a jquery datatable by passing an array to it, the controller pass an array of users using <code>ViewBag</code> as following:</p>
  <pre><code>userInfo[] users = _context.userInfo.ToArray();
  ViewBag.UsersArray = users;
  </code></pre>
  <p>In the view, I used <code>ViewBag.UsersArray</code> as a data source for the jquery datatable:</p>
  <pre><code>&lt;script&gt;
      $(document).ready(function () {
          $('#users').DataTable({
              data: @ViewBag.UsersArray,
              columns: [
                  { data: 'id' },
                  { data: 'username' },
                  { data: 'balance' },
                  { data: 'contract_id' }
              ]
          });
      });
  &lt;/script&gt;
  </code></pre>
  <p>I always got Unexpected token ']'
  <a href="https://i.stack.imgur.com/SvIn1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SvIn1.png" alt="enter image description here" /></a></p>