One object. Any format.
Prism serializes ordinary C# objects as Prism Binary, JSON, XML, YAML, TOML, or CBOR through a single API.
Current release: 1.0.2.
Install Sunmeat.Prism from NuGet:
dotnet add package Sunmeat.Prism --version 1.0.2Or install the latest available version:
dotnet add package Sunmeat.PrismA single package includes all six codecs. It targets .NET 8, 9, 10, and 11.
See the runtime and platform verification details.
using Sunmeat.Prism;
var person = new Person
{
Name = "Олена 🌻",
Age = 29,
IsAdult = true,
Password = "local-only"
};
byte[] binary = Prism.Serialize(person);
Person restored = Prism.Deserialize<Person>(binary);
var jsonCopy = Prism.FromJson<Person>(Prism.ToJson(person));
var xmlCopy = Prism.FromXml<Person>(Prism.ToXml(person));
var yamlCopy = Prism.FromYaml<Person>(Prism.ToYaml(person));
var tomlCopy = Prism.FromToml<Person>(Prism.ToToml(person));
var cborCopy = Prism.FromCbor<Person>(Prism.ToCbor(person));
public sealed class Person
{
public string Name { get; set; } = "";
public int Age { get; set; }
public bool IsAdult;
[NonSerialize]
public string Password { get; set; } = "";
}Prism includes public fields and restorable public properties by default.
[NonSerialize] excludes a member in both directions for all formats.
Positional records, parameterized constructors, init-only properties, and common immutable collections are supported.
using System.Security.Cryptography;
using Sunmeat.Prism;
await Prism.SaveAsync(
person,
"person.yaml",
cancellationToken: cancellationToken);
var restored = await Prism.LoadAsync<Person>(
"person.yaml",
cancellationToken: cancellationToken);
Prism.Save(person, "person.data", PrismFormat.Cbor);
var options = new PrismOptions
{
Compress = true,
EncryptionKey = RandomNumberGenerator.GetBytes(32)
};
byte[] encrypted = Prism.Serialize(person, options);
var decrypted = Prism.Deserialize<Person>(encrypted, options);
string json = Prism.ToJson(person);
string yaml = Prism.ConvertText(
json,
PrismFormat.Json,
PrismFormat.Yaml);
byte[] binary = Prism.Convert<Person>(
json,
PrismFormat.Json,
PrismFormat.Binary);The unencrypted binary payload uses a reversible byte transformation.
Use AES-GCM for confidentiality and authentication, and manage the key separately from the document.
| Format | Main use |
|---|---|
| Prism Binary | Type-driven, compact payloads with strict schema matching, optional Brotli and AES-GCM |
| JSON | UTF-8 JSON objects, arrays, and values |
| XML | Prism's XML value vocabulary |
| YAML | Single-document YAML with string keys and a restricted scalar schema |
| TOML | TOML tables without null values or numeric precision loss on output |
| CBOR | Definite-length CBOR with byte strings, big integers, and decimal fractions |
Prism Binary is an alpha protocol. Changes to serialized member names or wire shapes affect schema compatibility.
Cycles require binary reference preservation and mutable contracts.
Each codec has representation limits, and conversion follows the shared value model.
Native AOT and trimming are unverified.
Prism maps models through one cached contract system.
Format codecs then handle the shared value representation.
The binary codec uses the CLR schema to write positional values. Extensions can supply an application converter or a complete format codec.
Use the pinned SDK and install the four target runtimes.
Run the following from the repository root before opening a pull request.
dotnet restore
dotnet format --verify-no-changes --no-restore
dotnet build -c Release
dotnet test -c Release
dotnet pack -c Release -o artifacts
bash scripts/check-package.sh artifactsKeep the binary fixture aligned with the protocol version and document wire changes.
Benchmark inputs, measured timings, allocations and payload sizes are available in the benchmark guide.
Benchmarks · Getting started · Publishing · MIT license
Independent .NET libraries with a shared philosophy: simple APIs, modularity and open source.
| Library | Purpose | NuGet / Status |
|---|---|---|
| Sunmeat.Prism (this project) | Serialization and format conversion | NuGet |
| Sunmeat.Pulse | Structured logging | NuGet |
| Sunmeat.Nexus | HTTP requests and API communication | NuGet |
| Sunmeat.Lens | Code analysis and architecture visualization | NuGet · Roslyn · Raster |
| Sunmeat.Guard | Validation and argument checks | NuGet |
| Sunmeat.Diff | Data comparison and patches | NuGet |
| Sunmeat.Morph | Object mapping and transformation | NuGet |
| Sunmeat.Forge | Synthetic data and test fixtures | NuGet |
| Sunmeat.Signal | Multichannel notifications | NuGet · Extensions.DependencyInjection |
| Sunmeat.Vault | Cryptography and secret storage | NuGet |
| Sunmeat.Portal | File systems, storage and backups | NuGet |
| Sunmeat.Scribe | Document generation and processing | In development |
| Sunmeat.Flux | In-process Mediator, CQRS and Event Bus | In development |
| Sunmeat.Synapse | Unified AI API and model routing | In development |
All published packages · Ecosystem website
Sunmeat.Prism is free, open-source software created and maintained by an independent developer.
If Prism saves you time, simplifies your code, or becomes a valuable part of your projects, consider supporting its continued development.
Your support helps fund:
- New features and serialization formats.
- Performance improvements and optimizations.
- Documentation, examples, and automated tests.
- Long-term maintenance and compatibility.
- New open-source .NET libraries and developer tools.
Every contribution, regardless of its size, makes a difference.
You can also support the project by starring the repository, reporting issues, contributing code, or sharing Prism with other developers.
Built with curiosity. Shared with the community.
Copyright © 2026 Oleksandr Zahoruiko · sunmeat.dev
