Net4x.Text.Json 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Net4x.Text.Json --version 1.0.0
                    
NuGet\Install-Package Net4x.Text.Json -Version 1.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="Net4x.Text.Json" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Net4x.Text.Json" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Net4x.Text.Json" />
                    
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 Net4x.Text.Json --version 1.0.0
                    
#r "nuget: Net4x.Text.Json, 1.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.
#:package Net4x.Text.Json@1.0.0
                    
#: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=Net4x.Text.Json&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Net4x.Text.Json&version=1.0.0
                    
Install as a Cake Tool

Net4x.Text.Json

Lightweight compatibility wrapper that exposes a subset of the System.Text.Json-style API, implemented on top of Newtonsoft.Json. Intended for projects that need the familiar JsonSerializer API but target older .NET frameworks.

Supported targets

  • .NET Framework 3.5
  • .NET Framework 4.0
  • .NET Framework 4.5
  • .NET Framework 4.6.2
  • .NET Standard 2.0

Purpose

This library provides:

  • JsonSerializer static helpers: Serialize<T>, Deserialize<T>, and stream overloads.
  • JsonSerializerOptions with commonly used options mapped to Newtonsoft.Json equivalents.
  • A simple JsonConverter<T> base for creating custom converters compatible with the options system.
  • A non-static implementation JsonSerializerNonStatic for direct usage or testing.

Internally it uses JsonConvert and JsonSerializerSettings from Newtonsoft.Json.

Installation

Add the package references required by your project:

  • Newtonsoft.Json (required)
  • Net4x.Text.Json (this project)

For modern SDK-style projects:


For older projects use the __Package Manager__ or the __Manage NuGet Packages__ dialog in Visual Studio.

## Basic usage

Serialize an object to JSON:

Serialize to a Stream (UTF-8):


Deserialize from a string:

Deserialize with a runtime type:


Deserialize from a `Stream`:

Options and configuration

JsonSerializerOptions exposes common switches and converts them to Newtonsoft.Json settings internally:

  • WriteIndentedFormatting.Indented
  • IgnoreNullValuesNullValueHandling.Ignore
  • PropertyNamingPolicy (Default | CamelCase) → ContractResolver with naming strategy
  • PropertyNameCaseInsensitive → default contract resolver (preserves names but options exist)
  • EnumsAsStrings → adds StringEnumConverter
  • ReferenceLoopHandling → maps to Newtonsoft.Json.ReferenceLoopHandling
  • ConvertersEnabled + Converters list → appended to JsonSerializerSettings.Converters

Example:


## Custom converters

Create converters by deriving from `System.Text.Json.JsonConverter<T>` and override `Read` and `Write`. The base writes/reads using `Newtonsoft.Json` primitives (via `JsonWriter`/`JsonReader`).

Example outline:

Then register with JsonSerializerOptions.Converters.

Tests

Unit tests (NUnit) demonstrate behavior for:

  • Static and non-static serialize/deserialize APIs
  • Stream overloads and null argument validation
  • Converter read/write behavior

See the Net4x.Text.Json.Tests project for examples and test cases.

Notes

  • This library is a pragmatic bridge, not a full implementation of System.Text.Json.
  • Behavior follows Newtonsoft.Json semantics where applicable.
  • Ensure your consuming project references Newtonsoft.Json.

License

This project is licensed under the Apache-2.0 license. See the LICENSE.txt file for details.

Product 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.  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. 
.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 net35 is compatible.  net40 is compatible.  net403 was computed.  net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 is compatible.  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. 
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.0.1 49 1/5/2026
1.0.0 47 12/30/2025