ApeFree.Protocols.Json
0.0.1.8-beta1022
dotnet add package ApeFree.Protocols.Json --version 0.0.1.8-beta1022
NuGet\Install-Package ApeFree.Protocols.Json -Version 0.0.1.8-beta1022
<PackageReference Include="ApeFree.Protocols.Json" Version="0.0.1.8-beta1022" />
paket add ApeFree.Protocols.Json --version 0.0.1.8-beta1022
#r "nuget: ApeFree.Protocols.Json, 0.0.1.8-beta1022"
// Install ApeFree.Protocols.Json as a Cake Addin #addin nuget:?package=ApeFree.Protocols.Json&version=0.0.1.8-beta1022&prerelease // Install ApeFree.Protocols.Json as a Cake Tool #tool nuget:?package=ApeFree.Protocols.Json&version=0.0.1.8-beta1022&prerelease
Jbin序列化与JsonRPC库
Jbin序列化库是一个高效、灵活的二进制序列化框架,专为性能和空间优化而设计。它与传统的JSON序列化紧密相关,但提供了一些显著的优势,特别是在处理大型数据结构和复杂对象时。
Jbin序列化优势
高效的二进制格式
Jbin序列化使用二进制格式存储数据,相比传统的JSON格式,它更加紧凑,可以显著减少数据的体积,从而减少存储空间和网络传输时间。
快速解析
由于Jbin格式的简洁性,它在解析时比JSON更快。这在需要处理大量数据或高频率更新数据的应用中尤为重要。
支持复杂数据类型
Jbin序列化支持包括基本数据类型、复杂对象、集合以及.NET特有的数据类型(如Point
、Size
、Bitmap
等)的序列化和反序列化。
与传统JSON的关系
Jbin序列化与JSON序列化紧密相关,它可以被视为JSON的一种二进制表示形式。Jbin格式在内部使用JSON的结构和类型信息,但以更紧凑的二进制形式存储。这使得Jbin在保持JSON的灵活性和可读性的同时,提供了更好的性能。
JsonRPC支持
本库还提供了JsonRPC协议的基础实现,包括请求和响应实体类。JsonRPC是一种轻量级的远程过程调用(RPC)协议,它使用JSON作为其传输格式。我们的实现旨在为未来的协议扩展和数据格式解析器提供一个坚实的基础。
快速上手
以下是如何使用Jbin序列化库对一个复杂对象进行序列化和反序列化的示例:
using ApeFree.Protocols.Json.Jbin;
using System;
using System.Drawing;
public class MyData
{
public string Name { get; set; }
public string Des { get; set; }
public long Id { get; set; }
public Point Location { get; set; }
public SizeF[] Size { get; set; }
public byte[] Data1 { get; set; }
public byte[] Data2 { get; set; }
public Bitmap Photo { get; set; }
public List<MyData> Child { get; set; }
}
// 创建一个测试对象
var obj = new MyData
{
Name = "parent",
Des = "parent node",
Location = new Point(100, 200),
Size = new SizeF[] { new SizeF(3.14f, 2.71f) },
Data1 = new byte[] { 1, 2, 3 },
Data2 = new byte[] { 4, 5, 6 },
Photo = new Bitmap(100, 100),
Child = new List<MyData>
{
new MyData { Name = "child", Des = "child node" }
}
};
// 序列化对象到Jbin格式
var jbinObject = JbinObject.FromObject(obj);
var jbinBytes = jbinObject.ToBytes();
// 反序列化Jbin格式回对象
var deserializedObj = jbinObject.ToObject<MyData>();
// 保存为文件(可选)
System.IO.File.WriteAllBytes("MyData.jbin", jbinBytes);
性能对比
在单元测试中,我们对比了Jbin序列化和传统JSON序列化的性能差异。以下是一些关键发现:
- Jbin序列化在处理大型和复杂数据结构时,比JSON序列化更快。
- Jbin格式的文件大小比JSON格式小,这在网络传输和存储时非常有用。
贡献
我们欢迎您为这个项目贡献代码!如果您有任何建议或发现问题,请随时提交Issue或Pull Request。
许可证
Jbin序列化与JsonRPC库遵循MIT许可证。详见LICENSE文件。
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net452 is compatible. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.5.2
- Newtonsoft.Json (>= 13.0.1)
- STTech.CodePlus (>= 1.7.2.1)
-
.NETStandard 2.0
- Newtonsoft.Json (>= 13.0.1)
- STTech.CodePlus (>= 1.7.2.1)
- System.Drawing.Common (>= 8.0.8)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on ApeFree.Protocols.Json:
Package | Downloads |
---|---|
ApeFree.ApeRpc.Mqtt
Package Description |
|
ApeFree.Reflection.Rpc
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.0.1.8-beta1022 | 30 | 10/22/2024 |
0.0.1.7-beta0918 | 62 | 9/18/2024 |
0.0.1.6-beta0904 | 50 | 9/4/2024 |
0.0.1.2-beta0329 | 69 | 3/28/2024 |