Regira Serializing provides JSON serialisation via the ISerializer contract defined in Common.
| Project | Package | Backend |
|---|---|---|
Serializing.Newtonsoft |
Regira.Serializing.Newtonsoft |
Newtonsoft.Json |
<PackageReference Include="Regira.Serializing.Newtonsoft" Version="6.*" />
Implements ISerializer. Registers as a singleton in most consuming projects.
```csharp no-compile ISerializer json = new Regira.Serializing.Newtonsoft.Json.JsonSerializer();
string s = json.Serialize(myObject);
MyType obj = json.Deserialize
### Options
| Property | Type | Default | Description |
|----------|------|---------|-------------|
| `EnumAsString` | `bool` | `true` | Serialise enums as their name, not integer |
| `BoolAsNumber` | `bool` | `true` | Serialise `bool` as `1`/`0` |
| `IgnoreNullValues` | `bool` | `true` | Omit null properties |
| `WriteIndented` | `bool` | `false` | Pretty-print JSON |
```csharp
ISerializer json = new JsonSerializer(new JsonSerializer.Options
{
EnumAsString = true,
WriteIndented = true
});
| Converter | Handles | Registered |
|---|---|---|
StringEnumConverter |
enum ↔ name | when EnumAsString is true |
BoolNumberConverter |
bool ↔ 0/1 |
when BoolAsNumber is true |
DateOnlyJsonConverter |
DateOnly |
always |
DateAndTimeConverter |
DateTime / DateTimeOffset |
always |
Independent of converters, the serializer always uses camelCase property naming (contract resolver) and ignores reference loops (ReferenceLoopHandling.Ignore).
csharp no-compile
services.AddSingleton<ISerializer, Regira.Serializing.Newtonsoft.Json.JsonSerializer>();
Apache License 2.0 — this package contains no license validation and no runtime limits. See LICENSE. A few companion packages are commercially licensed with a free tier; see the licensing overview.