SuperJsonProcessor 1.0.1

dotnet add package SuperJsonProcessor --version 1.0.1
                    
NuGet\Install-Package SuperJsonProcessor -Version 1.0.1
                    
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="SuperJsonProcessor" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SuperJsonProcessor" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="SuperJsonProcessor" />
                    
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 SuperJsonProcessor --version 1.0.1
                    
#r "nuget: SuperJsonProcessor, 1.0.1"
                    
#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 SuperJsonProcessor@1.0.1
                    
#: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=SuperJsonProcessor&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=SuperJsonProcessor&version=1.0.1
                    
Install as a Cake Tool

SuperJsonProcessor

This package provides a set of methods designed for efficient JSON manipulation, validation, and processing. The following core functionalities are included:

  • FlattenJson: Converts a nested JSON structure into a flat, key-value pair format.
  • UnFlattenJson: Reverts a flattened JSON structure back to its original nested format.
  • ValidateJson: Validates a JSON document against a predefined JSON schema.
  • ProcessLargeJson: Efficiently processes large JSON files in a memory-efficient way.

Features

FlattenJson

This method is useful for flattening deeply nested JSON objects into a flat key-value pair structure. It�s commonly used when you need to work with JSON data that needs to be queried or processed in a simpler format.

Usage:

string json = "{ 'user': { 'name': 'John', 'details': { 'age': 30, 'city': 'New York' } } }"; var flattenedJson = JsonUtility.FlattenJson(json); Console.WriteLine(flattenedJson); // Output: { "user.name": "John", "user.details.age": 30, "user.details.city": "New York" }

UnFlattenJson

This method restores a previously flattened JSON object back to its original nested structure. It's useful when you want to transform a flat JSON structure back to a hierarchical representation.

Usage:

string flattenedJson = "{ "user.name": "John", "user.details.age": 30, "user.details.city": "New York" }"; var unFlattenedJson = JsonUtility.UnFlattenJson(flattenedJson); Console.WriteLine(unFlattenedJson); // Output: { "user": { "name": "John", "details": { "age": 30, "city": "New York" } } }

ValidateJson

Validates a JSON document against a specified JSON schema. This method ensures that the input JSON follows the required structure and data types as defined in the schema.

Usage:

string json = @"{ 'name': 'John', 'age': 30 }"; string schema = @"{ 'type': 'object', 'properties': { 'name': {'type': 'string'}, 'age': {'type': 'integer'} }, 'required': ['name', 'age'] }"; bool isValid = JsonUtility.ValidateJson(json, schema); Console.WriteLine(isValid); // Output: True

ProcessLargeJson

This method allows you to process large JSON files efficiently by reading them token by token. It's particularly useful for handling large JSON files that can't fit into memory all at once.

Usage:

string filePath = "path/to/large.json"; Action<JToken> processAction = (token) ⇒ { // Process each token, for example, print its name field Console.WriteLine(token["name"]); };

JsonProcessor.ProcessLargeJson(filePath, processAction);

Installation

To install the package,use a package manager like

Install-Package SuperJsonProcessor

Requirements

.NET Core 3.1 or higher Newtonsoft.Json (for JSON manipulation)

License

This package is licensed under the MIT License. See the LICENSE file for more information.

Acknowledgements

Newtonsoft.Json for JSON parsing and manipulation. Newtonsoft.Json.Schema for JSON schema validation.

Contact

For any questions or issues, feel free to open an issue on GitHub or contact the maintainer at ujwalwatgule@gmail.com

Product Compatible and additional computed target framework versions.
.NET 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 was computed.  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

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.0.1 183 12/25/2024
1.0.0 151 12/25/2024