that\'s my function:
If you prefer a class try jsmodel. After converting the mvc view model to javascript it adds the benefit of retrieving DOM updates.
var jsmodel = new JSModel(@Html.Raw(Json.Encode(Model)));
Then anytime you want to get the latest state of the DOM do this to update your variable:
var model = jsmodel.refresh();
Website: http://chadkuehn.com/jquery-viewmodel-object-with-current-values/
There is also a nuget: https://www.nuget.org/packages/jsmodel/