Get Started
dotnet add package Nullean.Snapshots.Json --version 0.18.0
| Product | Versions |
|---|---|
| .NET |
README
Nullean.Snapshots.Json

JSON snapshots and inline JSON assertions for Nullean.Snapshots, compared as trees: key order ignored, numbers by value, differences reported by path with the line and column in the verified file.
Install
dotnet add package Nullean.Snapshots.Json
Quick start
using System.Text.Json.Serialization;
using AwesomeAssertions;
using Nullean.Snapshots.Json;
using Nullean.Snapshots.Trees;
public record Order(int Id, string Product, DateTimeOffset CreatedAt);
[JsonSerializable(typeof(Order))]
public partial class AppJson : JsonSerializerContext;
public class OrderTests
{
[Test]
public void Serializes()
{
var order = new Order(3, "kibana", DateTimeOffset.UtcNow);
var diff = new TreeDiffOptions { IgnorePaths = ["$.CreatedAt"] };
order.Should().MatchJsonSnapshot(AppJson.Default.Order, diff); // source-generated: AOT-safe
}
[Test]
public void Inline() =>
"""{ "name": "Kibana", "id": 2 }""".Should().MatchInlineJsonSnapshot("""
{ "id": 2, "name": "Kibana" }
""");
}
MatchJsonSnapshottakes JSON text, or an object with aJsonTypeInfo<T>(source-generated, AOT-safe) orJsonSerializerOptions(reflection).TreeDiffOptionsignores volatile paths ($.meta.generatedAt,$..id) or makes key order and number form count (StrictNumbers).BeJsonandMatchInlineJsonSnapshotcompare with JSON written in the test.- Use the text
MatchSnapshotinstead when the exact bytes matter, such as whitespace or key order on the wire.
Learn more
- Documentation: https://snapshots.nullean.net
- JSON snapshots: https://snapshots.nullean.net/formats/json/
- Source and issues: https://github.com/nullean/snapshots
Downloads by Version
Similar & Alternative Packages
Hand-picked matching NuGet libraries based on tags & ecosystem
Depended On By
Find packages that declare this package as a dependency. NuGet does not provide a reverse-dependency endpoint, so candidates are checked on demand.
Adoption Assessment
Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.
Compatibility metadata lists 2 target frameworks; confirm the exact target used by your application.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.