private static void Main(string[] args) { string json = "{" + "\"0592\" : \"厦门市\"," + "\"0351\" : \"太原市\"," + "\"0411\" : \"大连市\"," + "\"0459\" : \"大庆市\"" + "}"; JsonObjectReader rd = new JsonObjectReader(json); dynamic res = rd.GetObject(); IDictionary<string, object> d = (IDictionary<string, object>) res; foreach (var item in d) { Console.WriteLine("{0} = {1}", item.Key, item.Value); } Console.WriteLine("\n\n"); //=============================================================================== json = "{\"Name\":\"小明\", \"Age\":25, \"Email\":\"[email protected]\"}"; JsonObjectReader rd2 = new JsonObjectReader(json); dynamic res2 = rd2.GetObject(); Console.WriteLine("姓名:{0}", res2.Name); Console.WriteLine("年龄:{0}", res2.Age); Console.WriteLine("电邮:{0}", res2.Email); Console.Read(); }
private static void Main(string[] args) { string json = "{" + "\"0592\" : \"厦门市\"," + "\"0351\" : \"太原市\"," + "\"0411\" : \"大连市\"," + "\"0459\" : \"大庆市\"" + "}"; JsonObjectReader rd = new JsonObjectReader(json); dynamic res = rd.GetObject(); IDictionary <string, object> d = (IDictionary <string, object>)res; foreach (var item in d) { Console.WriteLine("{0} = {1}", item.Key, item.Value); } Console.WriteLine("\n\n"); //=============================================================================== json = "{\"Name\":\"小明\", \"Age\":25, \"Email\":\"[email protected]\"}"; JsonObjectReader rd2 = new JsonObjectReader(json); dynamic res2 = rd2.GetObject(); Console.WriteLine("姓名:{0}", res2.Name); Console.WriteLine("年龄:{0}", res2.Age); Console.WriteLine("电邮:{0}", res2.Email); Console.Read(); }