nightmaregaurav.systemtextjsonhelper 2.0.0

dotnet add package nightmaregaurav.systemtextjsonhelper --version 2.0.0                
NuGet\Install-Package nightmaregaurav.systemtextjsonhelper -Version 2.0.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="nightmaregaurav.systemtextjsonhelper" Version="2.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add nightmaregaurav.systemtextjsonhelper --version 2.0.0                
#r "nuget: nightmaregaurav.systemtextjsonhelper, 2.0.0"                
#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.
// Install nightmaregaurav.systemtextjsonhelper as a Cake Addin
#addin nuget:?package=nightmaregaurav.systemtextjsonhelper&version=2.0.0

// Install nightmaregaurav.systemtextjsonhelper as a Cake Tool
#tool nuget:?package=nightmaregaurav.systemtextjsonhelper&version=2.0.0                

SystemTextJsonHelper

SystemTextJsonHelper is a C# helper class lib that simplifies the process of serializing and deserializing objects using the System.Text.Json namespace. It provides a flexible and convenient way to handle JSON serialization and deserialization with customizable options.

Features

  • Serialize objects to JSON strings with customizable options.
  • Deserialize JSON strings back into objects with customizable options.
  • Easily set global serialization options for consistent behavior across the application.

Usage

To use the SystemTextJsonHelper in your project, follow these steps:

  1. Install the package from NuGet.
  2. import the SystemTextJsonHelper namespace.
  3. Configure global options using SetGlobalJsonSerializerOptions method of JsonHelper class.
  4. You can get current options using GetJsonSerializerOptions or GetJsonSerializerOptions to get default options.
  5. Access static methods Serialize or Deserialize from the JsonHelper class for serialization and deserialization.

Global Configuration

JsonHelper.SetGlobalJsonSerializerOptions(options => {
    // Customize the JsonSerializerOptions here
    options.IncludeFields = true;
    return options;
});

Serialization

var myObject = new MyCustomObject();
string json = JsonHelper.Serialize(myObject);

// With custom options:
string customJson = JsonHelper.Serialize(myObject, options => {
    // Customize the JsonSerializerOptions here
    options.IncludeFields = true;
    return options;
});

Deserialization

string jsonString = "{\"propertyName\": \"propertyValue\"}";
MyCustomObject deserializedObject = JsonHelper.Deserialize<MyCustomObject>(jsonString);

// With custom options:
MyCustomObject customDeserializedObject = JsonHelper.Deserialize<MyCustomObject>(jsonString, options => {
    // Customize the JsonSerializerOptions here
    options.PropertyNameCaseInsensitive = true;
    return options;
});

License

SystemTextJsonHelper is released under the MIT License. You can find the full license details in the LICENSE file.

Made with ❤️ by NightmareGaurav.


Open For Contribution

We welcome contributions from the community. If you have suggestions, bug reports, or feature requests, please feel free to open issues or pull requests on GitHub.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net7.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on nightmaregaurav.systemtextjsonhelper:

Package Downloads
nightmaregaurav.rediscachehelper

A C# utility library that provides caching functionality using the StackExchange.Redis library without DI. It simplifies the process of storing and retrieving data from a Redis cache, allowing for efficient and reliable caching of objects.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.0 158 3/8/2024
1.0.1 170 8/17/2023
1.0.0 177 8/16/2023