I would like to print a json literal inside of an cshtml page (razor), I want to populate a json object in javascript and be ready when the page load, and not wait until the page load and then make an ajax call.
What I'm trying to do is something like
/*Some view*/
@{
ViewBag.Title = "Some title";
}
<script>
_SERVER_["someVar"] ="@SomeClass.Models.MovimientosMotivosModel.getMyarray()";
</script>
The problem is when I try to serialize the json all the double quotes get replace be html encoding and my json became a mess... how can achieved this?