I have this code and it work perfectly:
<script>
$(function() {
var modelAsString = @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model));
myProject.initialize(ko.mapping.fromJS(modelAsString));
});
</script>
Note that this script is directly in my view (e.g. MyPage.cshtml)
I'm just wondering why I must use the function fromJS instead of fromJSON.
If I use fromJSON, there is no error but it seems like my viewmodel is not created correctly.
And if possible, it would be greatly appreciated to have an example where I can use fromJSON with the same context; a case where I directly get the Model from the view instead of getting it from an ajax query.