These are the models I am working with:
public class ModelA
{
List<ModelB> ModelB {get;set;}
}
public class ModelB
{
List<ModelC> ModelC {get;set}
}
In an attempt to convert these models into my view, I referred to this answer.
<script>
var modelB = '@Html.Raw(Json.Encode(Model.ModelB))';
var modelBData = JSON.parse(modelB);
// However, I encountered an issue when trying to convert ModelC into a javascript array.
var modelC = '@Html.Raw(Json.Encode(Model.ModelB.ModelC))';
</script>
I was able to convert Model B into a JavaScript array successfully, but struggled with converting Model C. Can someone please help me figure out how to convert the list of ModelC within ModelB into a JavaScript array? Any assistance in identifying where I may be making a mistake would be greatly appreciated.