Joy.Json.Newtonsoft 0.0.2

dotnet add package Joy.Json.Newtonsoft --version 0.0.2
                    
NuGet\Install-Package Joy.Json.Newtonsoft -Version 0.0.2
                    
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="Joy.Json.Newtonsoft" Version="0.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Joy.Json.Newtonsoft" Version="0.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Joy.Json.Newtonsoft" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Joy.Json.Newtonsoft --version 0.0.2
                    
#r "nuget: Joy.Json.Newtonsoft, 0.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Joy.Json.Newtonsoft@0.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Joy.Json.Newtonsoft&version=0.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Joy.Json.Newtonsoft&version=0.0.2
                    
Install as a Cake Tool

Security

class Person
{
    public string? Name { get; set; }
    [Security("MaskMobile")]
    public string? Mobile { get; set; }
    [Security("Aes")]
    public string? IdCard { get; set; }
    public string[]? Contacts { get; set; }

    [OnSerialized]
    public static void OnSerialized(StreamingContext streaming)
    {
        Debug.WriteLine("x");
    }
}

public class SecurityTest
{
    [Fact]
    public void Test()
    {
        var ecurityOptions = new SymmetricOptions(SymmetricAlgr.Aes, SecurityEncoding.LowerHex)
                    .SetKeyIv("A432833714D886A6A432833714D886A6", "A432833714D886A6");
        using var sym = new Symmetric(ecurityOptions);
        SecurityContext context = new()
        {
            Handlers = new()
            {
                ["MaskMobile"] = () => new MaskHandler(range: ^8..^4),
                ["Aes"] = () => new SymmetricHandler(sym)
            }
        };
        var settings = new JsonSerializerSettings
        {
            ContractResolver = new SecurityContractResolver(context)
        };

        Person b = new()
        {
            Name = "Jack",
            Mobile = "13456788765",
            IdCard = "430181",
            Contacts = ["134", "156"]
        };
        var jsonActual = JsonConvert.SerializeObject(b, settings);
        var jsonExpect = """
        {"Name":"Jack","Mobile":"134****8765","IdCard":"471ba8e398992490536efe7b30b58684","Contacts":["134","156"]}
        """;
        Assert.Equal(jsonActual, jsonExpect);
    }

    [Fact]
    public void Test2()
    {
        var ecurityOptions = new SymmetricOptions(SymmetricAlgr.Aes, SecurityEncoding.LowerHex)
                    .SetKeyIv("A432833714D886A6A432833714D886A6", "A432833714D886A6");
        using var sym = new Symmetric(ecurityOptions);
        SecurityContext context = new()
        {
            Handlers = new()
            {
                ["MaskMobile"] = () => new MaskHandler(range: ^8..^4),
                ["Aes"] = () => new SymmetricHandler(sym)
            }
        };
        var settings = new JsonSerializerSettings
        {
            ContractResolver = new SecurityContractResolver(context)
        };

        var json = """
        {"Name":"Jack","Mobile":"134****8765","IdCard":"471ba8e398992490536efe7b30b58684","Contacts":["134","156"]}
        """;
        var b = JsonConvert.DeserializeObject<Person>(json, settings);
        Assert.NotNull(b);
        Assert.Equal("430181", b.IdCard);
    }
}
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Joy.Json.Newtonsoft:

Package Downloads
Joy.Ehospital.Supervisor.Tianjin

天津互联网医院Ver1.9

Joy.Jd.Health

Package Description

Joy.EventDriven

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.2 36 5/23/2026
0.0.1 302 4/30/2024