Net4x.Text.Json
1.0.0.1
dotnet add package Net4x.Text.Json --version 1.0.0.1
NuGet\Install-Package Net4x.Text.Json -Version 1.0.0.1
<PackageReference Include="Net4x.Text.Json" Version="1.0.0.1" />
<PackageVersion Include="Net4x.Text.Json" Version="1.0.0.1" />
<PackageReference Include="Net4x.Text.Json" />
paket add Net4x.Text.Json --version 1.0.0.1
#r "nuget: Net4x.Text.Json, 1.0.0.1"
#:package Net4x.Text.Json@1.0.0.1
#addin nuget:?package=Net4x.Text.Json&version=1.0.0.1
#tool nuget:?package=Net4x.Text.Json&version=1.0.0.1
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:
JsonSerializerstatic helpers:Serialize<T>,Deserialize<T>, and stream overloads.JsonSerializerOptionswith commonly used options mapped toNewtonsoft.Jsonequivalents.- A simple
JsonConverter<T>base for creating custom converters compatible with the options system. - A non-static implementation
JsonSerializerNonStaticfor 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:
WriteIndented→Formatting.IndentedIgnoreNullValues→NullValueHandling.IgnorePropertyNamingPolicy(Default | CamelCase) →ContractResolverwith naming strategyPropertyNameCaseInsensitive→ default contract resolver (preserves names but options exist)EnumsAsStrings→ addsStringEnumConverterReferenceLoopHandling→ maps toNewtonsoft.Json.ReferenceLoopHandlingConvertersEnabled+Converterslist → appended toJsonSerializerSettings.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.Jsonsemantics 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 | 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. 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. |
-
.NETFramework 3.5
- Net4x.BaseExtensions (>= 1.3.1.14)
- Newtonsoft.Json (>= 13.0.4)
-
.NETFramework 4.0
- Net4x.BaseExtensions (>= 1.3.1.14)
- Newtonsoft.Json (>= 13.0.4)
-
.NETFramework 4.5
- Net4x.BaseExtensions (>= 1.3.1.14)
- Newtonsoft.Json (>= 13.0.4)
-
.NETFramework 4.6.2
- Net4x.BaseExtensions (>= 1.3.1.14)
- Newtonsoft.Json (>= 13.0.4)
-
.NETStandard 2.0
- Net4x.BaseExtensions (>= 1.3.1.14)
- Newtonsoft.Json (>= 13.0.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.