Moka.Blazor.Json.Abstractions 0.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Moka.Blazor.Json.Abstractions --version 0.2.0
                    
NuGet\Install-Package Moka.Blazor.Json.Abstractions -Version 0.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Moka.Blazor.Json.Abstractions" Version="0.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Moka.Blazor.Json.Abstractions" Version="0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="Moka.Blazor.Json.Abstractions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Moka.Blazor.Json.Abstractions --version 0.2.0
                    
#r "nuget: Moka.Blazor.Json.Abstractions, 0.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Moka.Blazor.Json.Abstractions@0.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Moka.Blazor.Json.Abstractions&version=0.2.0
                    
Install as a Cake Addin
#tool nuget:?package=Moka.Blazor.Json.Abstractions&version=0.2.0
                    
Install as a Cake Tool

Moka.Blazor.Json

A high-performance Blazor JSON viewer and editor component with virtualized rendering, lazy parsing for large documents, search, theming, and extensible context menus.

NuGet License: MIT

Features

  • Virtualized rendering — handles documents up to 2 GB with smooth scrolling
  • Lazy parsing — documents over 50 MB use byte-offset indexing with on-demand subtree parsing
  • Inline editing — double-click to edit values, rename keys, add/delete nodes with undo/redo
  • Search — plain text, regex, case-sensitive with match navigation; streaming search for large docs
  • Theming — light, dark, auto (system preference), or fully custom via CSS variables
  • Settings panel — built-in gear menu for runtime configuration of all display/behavior settings
  • Toolbar modes — text-only, icon-only, or icon+text toolbar display
  • Context menu — built-in actions + extensible custom actions with type/property filtering
  • Breadcrumb navigation — clickable path segments for easy traversal
  • Key sorting — sort object keys alphabetically (single level or recursive)
  • Node scoping — zoom into any subtree as if it were the root
  • Zero external dependencies — built on System.Text.Json
  • Multi-target — supports .NET 9 and .NET 10

Packages

Package Description
Moka.Blazor.Json Main component library
Moka.Blazor.Json.Abstractions Interfaces and models for programmatic access
Moka.Blazor.Json.Diagnostics Debug overlay for lazy parsing diagnostics

Installation

dotnet add package Moka.Blazor.Json

Quick Start

1. Register services

// Program.cs
builder.Services.AddMokaJsonViewer();

2. Add the component

@using Moka.Blazor.Json.Components

<MokaJsonViewer Json="@myJson" />

@code {
    private string myJson = """{"name":"Alice","age":30,"tags":["dev","admin"]}""";
}

3. Two-way binding

<MokaJsonViewer @bind-Json="myJson" ReadOnly="false" />

@code {
    private string myJson = """{"name":"Alice"}""";
    // myJson updates automatically when the document is modified
}

Parameters

Parameter Type Default Description
Json string? null JSON string to display
JsonStream Stream? null Stream for large documents
Theme MokaJsonTheme Auto Auto, Light, Dark, or Inherit
ShowToolbar bool true Show the toolbar
ShowBottomBar bool true Show the status bar
ShowBreadcrumb bool true Show the breadcrumb path
ShowLineNumbers bool false Show line numbers
ShowSettingsButton bool? null Show settings gear in toolbar (defaults from DI options)
ReadOnly bool true Disable editing
MaxDepthExpanded int 2 Initial expansion depth
Height string "400px" Component height
ToolbarMode MokaJsonToolbarMode? null Text, Icon, or IconAndText
ToggleStyle MokaJsonToggleStyle Triangle Triangle, Chevron, PlusMinus, Arrow
ToggleSize MokaJsonToggleSize Small ExtraSmall through ExtraLarge
CollapseMode MokaJsonCollapseMode Depth Depth, Root, or Expanded
WordWrap bool true Enable word wrapping
OnNodeSelected EventCallback<JsonNodeSelectedEventArgs> Fires when a node is clicked
OnJsonChanged EventCallback<JsonChangeEventArgs> Fires when JSON is modified
JsonChanged EventCallback<string?> Two-way binding callback
OnError EventCallback<JsonErrorEventArgs> Fires on parse/runtime errors
ContextMenuActions IReadOnlyList<MokaJsonContextAction>? null Custom context menu actions
ToolbarExtra RenderFragment? null Extra toolbar content

Configuration

builder.Services.AddMokaJsonViewer(options =>
{
    options.DefaultTheme = MokaJsonTheme.Dark;
    options.DefaultToolbarMode = MokaJsonToolbarMode.IconAndText;
    options.DefaultExpandDepth = 3;
    options.MaxDocumentSizeBytes = 2L * 1024 * 1024 * 1024; // 2 GB
    options.LazyParsingThresholdBytes = 50 * 1024 * 1024;   // 50 MB
    options.MaxClipboardSizeBytes = 100 * 1024 * 1024;      // 100 MB
    options.SearchDebounceMs = 300;
    options.ShowSettingsButton = true;
});

Programmatic Control

The component implements IMokaJsonViewer for programmatic access:

<MokaJsonViewer @ref="_viewer" Json="@json" />

@code {
    private MokaJsonViewer _viewer = null!;

    private async Task NavigateToUser()
    {
        await _viewer.NavigateToAsync("/users/0/name");
    }

    private async Task Search()
    {
        var matchCount = await _viewer.SearchAsync("error", new JsonSearchOptions
        {
            CaseSensitive = false,
            UseRegex = true,
            SearchKeys = true,
            SearchValues = true
        });
    }
}

Available methods:

  • NavigateToAsync(jsonPointer) — Navigate to a JSON Pointer path
  • ExpandToDepth(depth) — Expand nodes to depth (-1 for all)
  • ExpandAll() / CollapseAll() — Expand or collapse the entire tree
  • SearchAsync(query, options) — Search with optional regex/case sensitivity
  • NextMatch() / PreviousMatch() — Navigate search results
  • ClearSearch() — Clear search state
  • GetJson(indented) — Get the current JSON as a string

Custom Context Menu Actions

private readonly List<MokaJsonContextAction> _actions =
[
    new MokaJsonContextAction
    {
        Id = "open-url",
        Label = "Open URL",
        ShortcutHint = "Enter",
        Order = 500,
        HasSeparatorBefore = true,
        IsVisible = ctx => ctx.ValueKind == JsonValueKind.String
                           && ctx.RawValuePreview.StartsWith("\"http", StringComparison.OrdinalIgnoreCase),
        OnExecute = ctx =>
        {
            var url = ctx.RawValuePreview.Trim('"');
            // Open URL...
            return ValueTask.CompletedTask;
        }
    }
];
<MokaJsonViewer Json="@json" ContextMenuActions="_actions" />

Theming

@* Built-in themes *@
<MokaJsonViewer Json="@json" Theme="MokaJsonTheme.Dark" />
<MokaJsonViewer Json="@json" Theme="MokaJsonTheme.Light" />
<MokaJsonViewer Json="@json" Theme="MokaJsonTheme.Auto" />

@* Custom theme: use Inherit + your own CSS variables *@
<MokaJsonViewer Json="@json" Theme="MokaJsonTheme.Inherit" />

Override CSS custom properties for full control — see Theming documentation.

Diagnostics

For development, add the diagnostics package to monitor lazy parsing performance:

dotnet add package Moka.Blazor.Json.Diagnostics
@using Moka.Blazor.Json.Diagnostics.Components

<MokaJsonViewer @ref="_viewer" Json="@json" />
<MokaJsonDebugOverlay Viewer="_viewer" Enabled="true" />

The overlay shows real-time coverage, parse stats, cache hit rates, and recent parse operations.

Keyboard Shortcuts

Shortcut Action
Ctrl+F Toggle search
F3 / Enter Next match
Shift+F3 Previous match
Esc Close search
Ctrl+Z Undo (edit mode)
Ctrl+Y Redo (edit mode)

Documentation

Full documentation: jacobwi.github.io/Moka.Blazor.Json

Project Structure

src/
  Moka.Blazor.Json/              # Main component library
  Moka.Blazor.Json.Abstractions/ # Interfaces and models
  Moka.Blazor.Json.Diagnostics/  # Debug overlay for lazy parsing
tests/
  Moka.Blazor.Json.Tests/        # Unit + bUnit component tests
  Moka.Blazor.Json.Benchmarks/   # Performance benchmarks
samples/
  Moka.Blazor.Json.Demo/         # Interactive demo application

License

MIT

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Moka.Blazor.Json.Abstractions:

Package Downloads
Moka.Blazor.Json

A high-performance, zero-dependency Blazor JSON viewer and editor component with virtualization, theming, and streaming support.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.5.1 160 4/2/2026
0.5.0 143 4/2/2026
0.4.4 143 4/2/2026
0.4.3 141 4/2/2026
0.4.2 136 3/31/2026
0.4.1 131 3/31/2026
0.4.0 151 3/27/2026
0.3.0 120 3/26/2026
0.2.0 116 3/26/2026
0.1.10 125 3/17/2026
0.1.9 125 3/17/2026
0.1.8 128 3/16/2026
0.1.7 114 3/16/2026
0.1.6 113 3/16/2026
0.1.5 117 3/15/2026
0.1.4 110 3/15/2026
0.1.3 107 3/15/2026
0.1.2 114 3/14/2026
0.1.1 118 3/14/2026
0.1.0 125 3/14/2026