public ActionResult Index()
{
string strfile = "aaa.txt";
string xpath = Server.MapPath("~/" + strfile);
//FileStream myfs = new FileStream(xpath, FileMode.Open);
//myfs.Close();
StreamReader sr = new StreamReader(xpath, System.Text.Encoding.Default);
String input = sr.ReadToEnd();
sr.Close();
//ViewBag.Texts = input;
//JArray ja = (JArray)JsonConvert.DeserializeObject(input);
//第一种方法
//DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(List<modeldel>));
//MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(input));
//object ob = serializer.ReadObject(stream);
//List<modeldel> list = (List<modeldel>)ob;
//第二种方法
List<modeldel> modlist = JsonConvert.DeserializeObject<List<modeldel>>(input);
return View();
}
public class modeldel
{
public int id { get; set; }
public string text { get; set; }
public string state { get; set; }
public List<modeldel> children { get; set; }
}