C#的JSON开发包 LitJSON
openkk
13年前
<div id="p_fullcontent" class="detail"> <p>LitJSON 是一个小型快速的用于处理 JSON 格式数据的 C# 和 .NET 的开发包。</p> <p>示例代码:</p> <pre class="brush:c#; toolbar: true; auto-links: false;">using LitJson; using System; public class Person { // Person members are defined here ... } public class JsonSample { public static void Main () { PersonToJson (); JsonToPerson (); } public static void PersonToJson () { Person bill = new Person (); bill.Name = "William Shakespeare"; bill.Age = 51; bill.Birthday = new DateTime (1564, 4, 26); string json_bill = JsonMapper.ToJson (bill); Console.WriteLine (json_bill); // {"Name":"William Shakespeare","Age":51,"Birthday":"04/26/1564 00:00:00"} } public static void JsonToPerson () { string json = @" { ""Name"" : ""Thomas More"", ""Age"" : 57, ""Birthday"" : ""02/07/1478 00:00:00"" }"; Person thomas = JsonMapper.ToObject<Person> (json); Console.WriteLine ("Thomas' age: {0}", thomas.Age); // Thomas' age: 57 } }</pre> <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1324129292453" target="_blank">http://www.open-open.com/lib/view/home/1324129292453</a></p> <p></p> </div>