'IJsonHelper' does not contain a definition for 'Encode'

Your answer can be simplified from:

sourcearray = JSON.parse('@Html.Raw(Json.Serialize(allusers))');

To:

sourcearray = @Json.Serialize(allusers);

Explanation:

  1. Json.Serialize() returns IHtmlContent, which does not need to be wrapped inside @Html.Raw() to preserve special characters.
  2. The text returned by @Json.Serialize() is already valid javascript object syntax. You're better off using it as is, rather than converting it to a string by wrapping it in quotes and then converting that string to an object via JSON.Parse().

I managed to do what I needed with

sourcearray = JSON.parse('@Html.Raw(Json.Serialize(allusers))');