Consoul.Text.Json
3.0.0
dotnet add package Consoul.Text.Json --version 3.0.0
NuGet\Install-Package Consoul.Text.Json -Version 3.0.0
<PackageReference Include="Consoul.Text.Json" Version="3.0.0" />
<PackageVersion Include="Consoul.Text.Json" Version="3.0.0" />
<PackageReference Include="Consoul.Text.Json" />
paket add Consoul.Text.Json --version 3.0.0
#r "nuget: Consoul.Text.Json, 3.0.0"
#:package Consoul.Text.Json@3.0.0
#addin nuget:?package=Consoul.Text.Json&version=3.0.0
#tool nuget:?package=Consoul.Text.Json&version=3.0.0
Consoul.Text.Json
Consoul.Text.Json is the optional System.Text.Json integration for Consoul's MVC-style object editor and JSON display helpers. It keeps the core Consoul package free of System.Text.Json while allowing applications to opt into platform JSON serialization, syntax-colored JSON snapshots, and JSON-style value rendering inside the shared form document editor.
For 3.0.0, read the documentation index, migration guide, and release notes. Versioned documentation links become available when the release tag is published.
Installation
After the package is published to your configured source:
dotnet add package Consoul.Text.Json --version 3.0.0
See the NuGet guide for local builds, NuGet.org, and authenticated GitHub Packages setup. These instructions do not imply that the package is already published.
This package depends on:
| Package | Purpose |
|---|---|
Consoul |
Core MVC-style object editor views and console rendering. |
System.Text.Json |
JSON serialization for form/object-editor values and JSON snapshot rendering. |
Basic Usage
Call UseSystemTextJsonForFormValues() before rendering an EditObjectView directly or through DynamicView<TModel>.EditModel(...):
using ConsoulLibrary;
ConsoulTextJsonExtensions.UseSystemTextJsonForFormValues();
var settings = new DeploymentSettings
{
Environment = "staging",
RetryCount = 3
};
var editor = Consoul.EditObject(settings);
editor.Render();
The form document editor's JSON-style value layout will use JsonSerializer.Serialize(...) for values.
Render JSON Snapshots
Use ConsoulTextJsonExtensions.Json(...) for raw JSON or JsonValue(...) for model snapshots:
using ConsoulLibrary;
ConsoulTextJsonExtensions.Json("{\"status\":\"ready\",\"count\":3}");
ConsoulTextJsonExtensions.JsonValue(new
{
Environment = "Development",
Preview = true,
RetryCount = 3
}, new JsonTextOptions
{
Width = 64
});
If your MVC-style view or service already depends on IAnsiConsole, use the injected-console extension methods so the same JSON rendering flows through the active facade, fake console, or writer-backed console:
public sealed class DiagnosticsPanel
{
private readonly IAnsiConsole _console;
public DiagnosticsPanel(IAnsiConsole console)
{
_console = console;
}
public void Render(DeploymentSettings settings)
{
_console.JsonValue(settings, new JsonTextOptions { Width = 64 });
}
}
JSON rendering is token-colored, pretty-printed by default, and bounded to the current Consoul terminal width. Invalid JSON renders a friendly bounded error unless JsonTextOptions.ThrowOnInvalidJson is enabled.
Use JsonTextEntry when a JSON snapshot should be captured, placed in a panel/layout, or returned from a model-backed view:
var snapshot = JsonTextEntry.FromValue(
settings,
options: new JsonTextOptions { Width = 56 });
Consoul.View("Diagnostics", settings)
.RenderModel(model => JsonTextEntry.FromValue(model, options: new JsonTextOptions { Width = 56 }))
.Option("Refresh", model => LoadLatest(model))
.Render();
Consoul.Panel(snapshot, title: "Settings Snapshot", width: 64, captureWidth: 56);
For Spectre-style snippets, use JsonText. It is still part of this optional package, so the core Consoul package remains free of System.Text.Json:
using ConsoulLibrary;
using ConsoulLibrary.Color;
AnsiConsole.Write(new JsonText("{\"status\":\"ready\",\"count\":3,\"items\":[1,2]}")
.Width(64)
.Indentation("..")
.MemberColor(Colors.Aqua)
.StringStyle(new Style(Colors.Green))
.NumberColor(Colors.Blue)
.BooleanStyle(new Style(Colors.Yellow))
.NullStyle(new Style(Colors.Red))
.BracesStyle(new Style(Colors.Magenta))
.BracketsStyle(new Style(Colors.DarkMagenta))
.ColonStyle(new Style(Colors.Cyan))
.CommaStyle(new Style(Colors.Gray)));
Model snapshots can use the same fluent builder with JsonText.FromValue(...):
using System.Text.Json;
AnsiConsole.Write(JsonText
.FromValue(settings, serializerOptions: new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
})
.Width(64)
.MemberColor(Colors.Aqua)
.NumberColor(Colors.Blue));
Initializer-style configuration is also supported when a reusable JSON snapshot should be built declaratively:
var json = new JsonText("{\"status\":\"ready\",\"items\":[1]}")
{
Width = 64,
Indentation = " ",
MemberStyle = new Style(Colors.Aqua),
StringStyle = new Style(Colors.Green),
NumberStyle = new Style(Colors.Blue),
BracesStyle = new Style(Colors.Magenta),
BracketsStyle = new Style(Colors.DarkMagenta),
ColonStyle = new Style(Colors.Cyan),
CommaStyle = new Style(Colors.Gray)
};
AnsiConsole.Write(json);
JsonText wraps JsonTextEntry, so it can be captured, placed in panels/layouts, or returned from MVC-style dynamic view sections just like other Consoul renderables.
Configure JsonSerializerOptions
Pass serializer options when you want custom formatting:
using ConsoulLibrary;
using System.Text.Json;
var options = new JsonSerializerOptions
{
WriteIndented = false,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
ConsoulTextJsonExtensions.UseSystemTextJsonForFormValues(options);
Reset To A Custom Serializer
The core editor exposes a serializer hook:
EditObjectView.FormValueSerializer = (value, type) =>
{
if (value == null)
{
return "null";
}
return $"\"{value}\"";
};
ConsoulTextJsonExtensions.UseSystemTextJsonForObjectEditor(...) and EditObjectView.JsonValueSerializer remain available as compatibility aliases for callers that adopted the original object-editor or JSON-editor terminology. New code should think of this package as the serializer/coloring companion for EditObjectView and reusable JsonTextEntry snapshots.
Installing this package is only necessary when you want System.Text.Json behavior specifically. The core package includes a lightweight dependency-free formatter for common value types.
When To Use This Package
Use Consoul.Text.Json when:
- You use
DynamicView<TModel>.EditModel(...)orEditObjectView. - You want JSON-style values to match
System.Text.Jsonbehavior. - You want syntax-colored JSON snapshots in MVC-style diagnostic or proof-of-concept views.
- You are comfortable carrying a
System.Text.Jsonpackage dependency in the consuming project.
Use only Consoul when the dependency-free form/object-editor formatter is enough.
License
Consoul.Text.Json is licensed under the GNU Lesser General Public License v3.0.
| 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 | net461 was computed. net462 was computed. 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. |
-
.NETStandard 2.0
- Consoul (>= 3.0.0)
- System.Text.Json (>= 8.0.5)
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 |
|---|---|---|
| 3.0.0 | 54 | 10/15/2026 |
3.0: dependency-light core, optional integrations, typed prompts, CLI commands, and responsive rendering. Breaking changes and known limitations: https://github.com/tbm0115/Consoul/blob/v3.0.0/docs/releases/3.0.0.md