1、添加引用
2、添加命名空间
using System.Web;using System.Web.Script.Serialization;
3、
OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.Multiselect = true; fileDialog.Title = "请选择文件"; fileDialog.Filter = "(*.txt)|*.txt"; if (fileDialog.ShowDialog() == DialogResult.OK) { string file = fileDialog.FileName; string text = System.IO.File.ReadAllText(file, Encoding.Default); JavaScriptSerializer js = new JavaScriptSerializer(); Dictionary
使用JObject
1、添加命名空间
using Newtonsoft.Json.Linq;
2、
var obj = JObject.Parse(text);