Simplerjiang.ConfigJsonSave
1.0.0
See the version list below for details.
dotnet add package Simplerjiang.ConfigJsonSave --version 1.0.0
NuGet\Install-Package Simplerjiang.ConfigJsonSave -Version 1.0.0
<PackageReference Include="Simplerjiang.ConfigJsonSave" Version="1.0.0" />
paket add Simplerjiang.ConfigJsonSave --version 1.0.0
#r "nuget: Simplerjiang.ConfigJsonSave, 1.0.0"
// Install Simplerjiang.ConfigJsonSave as a Cake Addin #addin nuget:?package=Simplerjiang.ConfigJsonSave&version=1.0.0 // Install Simplerjiang.ConfigJsonSave as a Cake Tool #tool nuget:?package=Simplerjiang.ConfigJsonSave&version=1.0.0
Simplerjiang.ConfigJsonSave
基于.net standard,用于.net 与 .net core的配置文件Json 及Json转换的类库
A Json Worker Class library, most easy way for write config file and read, base on .Net Standard.
使用非常简单
It's pretty easy to use.
为你的模型加上[DataContract] 和 [DataMember] 特性,不参与json的加上[IgnoreDataMember]
Add [DataContract] to your class, [DataMember] to your property. to ingnore property should use [IgnoreDataMember]
using System.Runtime.Serialization;
[DataContract]
public class TestClass
{
[DataMember]
public string Name { get; set; } = "aaaaInfo";
[DataMember]
public string Info { get; set; } = "BBBBInfo";
[DataMember]
public decimal Balance { get; set; } = 100m;
[DataMember]
public bool Flag { get; set; } = false;
[DataMember]
public int Number { get; set; } = 12345;
}
加上类库后
after using library
[TestMethod]
public void StrTest()
{
TestClass testClass = new TestClass()
{
Name = "test",
Info = "aaa",
Balance = 1m,
};
//将模型转换为json字符串 convert json string to model
var convertStr = Simplerjiang.ConfigJsonSave.JsonWorker.Out<TestClass>(testClass);
Trace.WriteLine(convertStr);
//将json字符串转换为模型 convert json string to model
var convertModel = Simplerjiang.ConfigJsonSave.JsonWorker.Get<TestClass>(convertStr);
Assert.AreEqual(convertModel.Balance, testClass.Balance);
}
[TestMethod]
public void WriteAndReadTest()
{
TestClass testClass = new TestClass()
{
Name = "test",
Info = "aaa",
Balance = 1m,
};
//保存路径 Save Path
var convertPath = System.IO.Path.Combine(Environment.CurrentDirectory, "test.json");
//保存json文件到路径 Save json file to path
Simplerjiang.ConfigJsonSave.JsonWorker.Write(testClass, convertPath);
//读取json文件从路径 Read json file from path
var convertModel = Simplerjiang.ConfigJsonSave.JsonWorker.Read<TestClass>(convertPath);
Assert.AreEqual(convertModel.Balance, testClass.Balance);
}
支持环境 Support Framework
.net core >= 2.0
.net >= 4.6.1
其他平台请看 Others Platfrom(without test):https://docs.microsoft.com/zh-cn/dotnet/standard/net-standard#net-implementation-support
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 | 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. |
-
.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.