var nationality = HttpContext.Current.Server.MapPath("~/Config/nationality.json"); string[] nationArr; using(StreamReader r=new StreamReader(nationality, Encoding.Default)) { string json = r.ReadToEnd(); var nation = json.ToObject<Nationality>(); nationArr = nation.Data.Select(n => n.Name).ToArray(); }
注意一定要加“Encoding.Default”防止中文乱码。