_覓 | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁 |
FrontPage › JSON一危一豢蠍
|
|
/* * Created by SharpDevelop. * User: dwa2007 * Date: 2012-12-21 * Time: ろ 4:04 * * To change this template use Tools | Options | Coding | Edit Standard Headers. */ using System; using Newtonsoft.Json.Linq; namespace json { class Program { public static void Main(string[] args) { string json = @"{ ""企"": ""ろ"", """": 25, ""焔"": """", ""蠍壱"": true, ""譯殊"": ""誤豪 豌蟲 覈"", ""濠鍵"": [""蟲"", """"], ""螳譟炎螻"": {""#"": 2, ""覯讌"": """", ""企┯"": ""豢""}, """": ""蟆所鍵 襷蟲 7"" }"; //Newtonsoft.Json. JObject obj = JObject.Parse(json); string name = (string)obj["企"]; int age = (int)obj[""]; string gender = (string)obj["焔"]; //Type Console.WriteLine(obj["濠鍵"].Type); Console.WriteLine(obj["螳譟炎螻"].Type); //Array JArray specialty = (JArray)obj["濠鍵"]; string specialty1 = (string)specialty[0]; string specialty2 = (string)specialty[1]; //Object JObject obj_family = JObject.Parse(obj["螳譟炎螻"].ToString()); int family_cnt = (int)obj_family["#"]; Console.WriteLine("企= {0}, ={1}, 焔={2}, 濠鍵={3}, 螳譟煙={4}", name, age, gender, specialty1, family_cnt); // TODO: Implement Functionality Here Console.Write("Press any key to continue . . . "); Console.ReadKey(true); } } } 谿語^豢螳 - Microsoft.CSharp - Microsoft.Web.Extensions using System.Web.Script.Serialization; //豢螳 using Microsoft.CSharp; //豢螳 try { var jss = new JavaScriptSerializer(); var data = jss.Deserialize<dynamic>(Row.json); Row.key_tinyint = Convert.ToByte(data["1"]); Row.key_smallint = Convert.ToInt16(data["2"]); Row.key_int = Convert.ToInt32(data["3"]); Row.key_bigint = Convert.ToInt64(data["4"]); Row.key_datetime = Convert.ToDateTime(data["5"]); Row.key_varchar = Convert.ToString(data["6"]); Row.key_bit = Convert.ToBoolean(data["7"]); Row.erroryn = false; } catch { Row.erroryn = true; } -- 蟾 2016-12-03 15:31:32
鏤
|
磯Μ 螳 誤 襷 る " 襦" " 豁れ伎" "語 蠏碁磯". 磯Μ 襷 る " 襷企朱" "願 朱 " "願 襾殊". (覦誤) |