jsonfx-master

所属分类:Unity3D
开发工具:C#
文件大小:2338KB
下载次数:0
上传日期:2020-06-23 23:55:05
上 传 者5685485
说明:  LitJson插件 十分好用的 类转josn文本
(A very useful class to Josn text for litjson plug-in)

文件列表:
Build.bat (4443, 2015-08-02)
Build_Launch.bat (44, 2015-08-02)
Build_Log.bat (126, 2015-08-02)
JsonFx.Tests.xunit (183, 2015-08-02)
JsonFx.sln (1692, 2015-08-02)
LICENSE.txt (1161, 2015-08-02)
Logo_128.png (10481, 2015-08-02)
keys (0, 2015-08-02)
keys\JsonFx_Key.pfx (1756, 2015-08-02)
keys\JsonFx_Key.snk (596, 2015-08-02)
lib (0, 2015-08-02)
lib\xunit.net (0, 2015-08-02)
lib\xunit.net\HTML.xslt (5755, 2015-08-02)
lib\xunit.net\NUnitXml.xslt (3638, 2015-08-02)
lib\xunit.net\xunit.console.clr4.exe (23552, 2015-08-02)
lib\xunit.net\xunit.console.clr4.exe.config (552, 2015-08-02)
lib\xunit.net\xunit.console.clr4.x86.exe (23552, 2015-08-02)
lib\xunit.net\xunit.console.clr4.x86.exe.config (556, 2015-08-02)
lib\xunit.net\xunit.console.exe (23552, 2015-08-02)
lib\xunit.net\xunit.console.exe.config (547, 2015-08-02)
lib\xunit.net\xunit.console.x86.exe (23552, 2015-08-02)
lib\xunit.net\xunit.console.x86.exe.config (551, 2015-08-02)
lib\xunit.net\xunit.dll (61952, 2015-08-02)
lib\xunit.net\xunit.dll.tdnet (201, 2015-08-02)
lib\xunit.net\xunit.extensions.dll (22528, 2015-08-02)
lib\xunit.net\xunit.extensions.xml (47784, 2015-08-02)
lib\xunit.net\xunit.gui.clr4.exe (484864, 2015-08-02)
lib\xunit.net\xunit.gui.clr4.x86.exe (484864, 2015-08-02)
lib\xunit.net\xunit.gui.exe (484864, 2015-08-02)
lib\xunit.net\xunit.gui.x86.exe (484864, 2015-08-02)
lib\xunit.net\xunit.installer.exe (593408, 2015-08-02)
lib\xunit.net\xunit.runner.msbuild.dll (25600, 2015-08-02)
lib\xunit.net\xunit.runner.tdnet.dll (8704, 2015-08-02)
lib\xunit.net\xunit.runner.utility.dll (44032, 2015-08-02)
lib\xunit.net\xunit.runner.utility.xml (58249, 2015-08-02)
lib\xunit.net\xunit.xml (124662, 2015-08-02)
packages (0, 2015-08-02)
... ...

# [JsonFx v2.0][1] - JSON serialization framework for .NET ## Distributed under the terms of an [MIT-style license][2] ### Compatible Runtimes: - .NET Framework 2.0, 3.0, 3.5, and 4.0 - Silverlight 3.0, 4.0 - Windows Phone 7 - Mono Framework 2.6 ### Serialization Features: - Unified interface for reading / writing [JSON][3], [BSON][4], XML, [JsonML][5] - Implements true LINQ-to-JSON (not simply LINQ-to-Objects over JSON types) - Naturally deserializes to standard CLR types, not JSON/XML-specific types - Supports reading/writing POCO classes - Supports reading/writing using DataContract, XmlSerialization, JsonName, attributes - Supports reading/writing using convention-based property renaming - Supports reading/writing C# 4.0 dynamic types - Supports reading/writing C# 3.0 Anonymous objects - Supports reading/writing LINQ queries - Supports custom reading/writing extensions & name resolution strategies - Dependency-injection-friendly for extremely flexible custom configurations - Stream-based serialization for reading/writing right off the wire - Provider allows automatic selection of serializer from Content-Type and Accept-Types HTTP headers ### Basic Examples: #### Serialize to/from dynamic types (default for .NET 4.0): var reader = new JsonReader(); var writer = new JsonWriter(); string input = @"{ ""foo"": true, ""array"": [ 42, false, ""Hello!"", null ] }"; dynamic output = reader.Read(input); Console.WriteLine(output.array[0]); // 42 string json = writer.Write(output); Console.WriteLine(json); // {"foo":true,"array":[42,false,"Hello!",null]} #### Serialize to/from standard CLR types (default for .NET 2.0/3.5): string input = @"{ ""first"": ""Foo"", ""last"": ""Bar"" }"; var output = reader.Read>(input); Console.WriteLine(output["first"]); // Foo output["middle"] = "Blah"; string json = writer.Write(output); Console.WriteLine(json); // {"first":"Foo","last":"Bar","middle":"Blah"} #### Serialize to/from Anonymous types string input = @"{ ""first"": ""Foo"", ""last"": ""Bar"" }"; var template = new { first=String.Empty, middle=String.Empty, last=String.Empty }; var output = reader.Read(input, template); Console.WriteLine(output.first); // Foo output = new { output.first, middle="Blah", output.last }; string json = writer.Write(output); Console.WriteLine(json); // {"first":"Foo","middle":"Blah","last":"Bar"} #### Serialize to/from custom types and LINQ queries [DataContract] public class Person { [DataMember(Name="id")] public long PersonID { get; set; } [DataMember(Name="first")] public string FirstName { get; set; } [DataMember(Name="last")] public string LastName { get; set; } } // respect DataContracts on the way in var reader = new JsonReader(new DataReaderSettings(new DataContractResolverStrategy())); // use convention over configuration on the way out var writer = new JsonWriter(new DataWriterSettings(new ConventionResolverStrategy(ConventionResolverStrategy.WordCasing.Lowercase, "-"))); string input = @"[ { ""id"": 1, ""first"": ""Foo"", ""last"": ""Bar"" }, { ""id"": 2, ""first"": ""etc."", ""last"": ""et al."" }, { ""id"": 3, ""first"": ""Blah"", ""last"": ""Yada"" } ]"; var people = reader.Query(input); var query = from person in people.ArrayItems() where person.PersonID == 1 || person.FirstName == "Blah" orderby person.PersonID select person; Console.WriteLine(query.Last().LastName); // Yada string json = writer.Write(query); Console.WriteLine(json); // [{"person-id":1,"first-name":"Foo","last-name":"Bar"},{"person-id":3,"first-name":"Blah","last-name":"Yada"}] #### Serialize to/from TCP socket: TcpClient tcpClient = new TcpClient(server, port); NetworkStream tcpStream = tcpClient.GetStream(); // read incrementally from incoming stream TextReader tcpReader = new StreamReader(tcpStream); Foo myFoo = new JsonReader.Read(tcpReader); // write directly to output stream TextWriter tcpWriter = new StreamWriter(tcpStream); new JsonWriter.Write(myFoo, tcpWriter); #### Fully customizable name resolution strategies // accept all variations! list in order of priority var resolver = new CombinedResolverStrategy( new JsonResolverStrategy(), // simple JSON attributes new DataContractResolverStrategy(), // DataContract attributes new XmlResolverStrategy(), // XmlSerializer attributes new ConventionResolverStrategy(ConventionResolverStrategy.WordCasing.PascalCase), // DotNetStyle new ConventionResolverStrategy(ConventionResolverStrategy.WordCasing.CamelCase), // jsonStyle new ConventionResolverStrategy(ConventionResolverStrategy.WordCasing.Lowercase, "-"), // xml-style new ConventionResolverStrategy(ConventionResolverStrategy.WordCasing.Uppercase, "_")); // CONST_STYLE // pass the combined resolver strategy into the settings object var reader = new JsonReader(new DataReaderSettings(resolver)); // link the settings objects to share resolver strategies and name lookup cache var writer = new JsonWriter(new DataWriterSettings(reader.Settings) { PrettyPrint=true }); #### Build REST services using dependency injection to configure auto-serializer selection // setup once for the lifespan of the application // POCO name resolution, share lookups among all instances var readerSettings = new DataReaderSettings(); var writerSettings = new DataWriterSettings(readerSettings); var jsonReader = new JsonFx.Json.JsonReader(readerSettings); var jsonWriter = new JsonFx.Json.JsonWriter(writerSettings); var xmlReader = new JsonFx.Xml.XmlReader(readerSettings); var xmlWriter = new JsonFx.Xml.XmlWriter(writerSettings); // list all the readers var readerProvider = new DataReaderProvider( jsonReader, xmlReader); // list all the writers var writerProvider = new DataWriterProvider( jsonWriter, xmlWriter); // ...later on a request comes in // incoming HTTP request headers string contentTypeHeader = myRequest.Headers[HttpRequestHeader.ContentType]; string acceptHeader = myRequest.Headers[HttpRequestHeader.Accept]; IDataReader deserializer = readerProvider.Find(contentTypeHeader); var requestData; using (var textReader = new StreamReader(myRequest.GetRequestStream())) { requestData = deserializer.Read(textReader); } // ...consume the data, generate a response var myResponse = ...; var responseData = ...; IDataWriter serializer = writerProvider.Find(acceptHeader, contentTypeHeader); using (var textWriter = new StreamWriter(myResponse.GetResponseStream())) { serializer.Write(responseData); } [1]: http://jsonfx.net [2]: http://jsonfx.net/license [3]: http://json.org [4]: http://bsonspec.org [5]: http://jsonml.org

近期下载者

相关文件


收藏者