LHZ.FastJson 1.6.0

.NET Standard 2.0 .NET Framework 4.0
dotnet add package LHZ.FastJson --version 1.6.0
NuGet\Install-Package LHZ.FastJson -Version 1.6.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LHZ.FastJson" Version="1.6.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add LHZ.FastJson --version 1.6.0
#r "nuget: LHZ.FastJson, 1.6.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install LHZ.FastJson as a Cake Addin
#addin nuget:?package=LHZ.FastJson&version=1.6.0

// Install LHZ.FastJson as a Cake Tool
#tool nuget:?package=LHZ.FastJson&version=1.6.0

LHZ.FastJson

轻巧便利的Json序列化和反序列化工具 <br/> Lightweight and convenient tool for JSON serialization and deserialization

序列化性能

LHZ.FastJson重构了序列化方法,拥有极高的序列化性能,下表为LHZ.FastJson、NewtonJson和System.Text.Json的序列化性能测试


BenchmarkDotNet=v0.13.1, OS=Windows 10.0.19044.1706 (21H2)
Intel Core i7-9700K CPU 3.60GHz (Coffee Lake), 1 CPU, 8 logical and 8 physical cores
.NET SDK=6.0.201
  [Host]     : .NET 6.0.3 (6.0.322.12309), X64 RyuJIT
  DefaultJob : .NET 6.0.3 (6.0.322.12309), X64 RyuJIT


Method Mean Error StdDev
LHZ.FastJson 7.014 μs 0.0298 μs 0.0279 μs
NewtonJson 18.943 μs 0.1786 μs 0.1671 μs
System.Text.Json 10.410 μs 0.0499 μs 0.0467 μs

如何安装

下面展示不同的安装方法,以安装LHZ.FastJson 1.3.3版本为例

Package Manager

Install-Package LHZ.FastJson -Version 1.5.0

.NET CLI

dotnet add package LHZ.FastJson --Version 1.5.0

package-reference

<PackageReference Include="LHZ.FastJson" Version="1.5.0" />

Paket CLI

paket add LHZ.FastJson --version 1.5.0

如何使用

使用LHZ.FastJson进行序列化

序列化代码示例

Student student = new Student
{
    NO = 1,
    Name = "lhz",
    Age = 18,
    Brithday = new DateTime(2002, 1, 1)
};

string jsonStr = LHZ.FastJson.JsonConvert.Serialize(student);

Console.WriteLine(jsonStr);

运行结果

PS C:\Users\admin\source\repos\LHZ.FastJson\LHZ.FastJson.Test> dotnet run
{"NO":1,"Name":"lhz","Age":18,"Brithday":"2000/1/1 0:00:00"}

使用LHZ.FastJson进行反序列化

反序列化代码示例

string str = "{\"NO\":1,\"Name\":\"lhz\",\"Age\":18,\"Brithday\":\"2000/1/1 0:00:00\"}";

Student student = JsonConvert.Deserialize<Student>(str);

Console.WriteLine("NO:{0},Name:{1},Age:{2},Brithday:{3}", student.NO, student.Name, student.Age, student.Brithday.ToString("yyyy-MM-dd"));

运行结果

PS C:\Users\admin\source\repos\LHZ.FastJson\LHZ.FastJson.Test> dotnet run
NO:1,Name:lhz,Age:18,Brithday:2000-1-1
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net40 net403 net45 net451 net452 net46 net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.0

    • No dependencies.
  • .NETFramework 4.5

    • No dependencies.
  • .NETFramework 4.6

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.6.0 150 8/20/2022
1.5.2 161 6/13/2022
1.5.1 168 6/12/2022
1.5.0 173 6/12/2022
1.4.2 253 8/19/2021
1.4.0 216 8/9/2021
1.3.6 257 6/7/2021
1.3.4 362 9/15/2020
1.3.3 323 8/11/2020
1.3.2 381 8/1/2020
1.3.1 386 8/1/2020
1.2.4 347 7/26/2020
1.2.3 407 7/19/2020
1.2.2 348 7/18/2020
1.2.1 392 7/18/2020
1.1.1 353 7/14/2020

优化了反序列化性能