169
rated 0 times
[
173]
[
4]
/ answers: 1 / hits: 5383
/ 11 Years ago, thu, january 9, 2014, 12:00:00
In controller I have
public JsonResult Index()
{
List<TutorialModel> models = new List<TutorialModel>();
model.TitleWord = Go;
model.Colors = new List<bool>();
model.Colors.Add(true);
model.Colors.Add(false);
model.Colors.Add(false);
model.Colors.Add(false);
model.PossibleAnswers = new List<string>();
model.PossibleAnswers.Add(1);
model.PossibleAnswers.Add(2);
model.PossibleAnswers.Add(3);
model.PossibleAnswers.Add(4);
string ser = (new System.Web.Script.Serialization.JavaScriptSerializer()).Serialize(model);
return Json(ser, JsonRequestBehavior.AllowGet);
}
And when In view I try to catch this Json result with
<script>
var values = json.parse(@Model)
</script>
And browser shows me my serialize string. How I can deserialize this json element and store in some variable.
My model for this Controller :
public class TutorialModel
{
public string TitleWord { get; set; }
public List<string> PossibleAnswers { get; set; }
public List<bool> Colors { get; set; }
}
More From » json