Celly.Json 1.7.2

dotnet add package Celly.Json --version 1.7.2
                    
NuGet\Install-Package Celly.Json -Version 1.7.2
                    
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="Celly.Json" Version="1.7.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Celly.Json" Version="1.7.2" />
                    
Directory.Packages.props
<PackageReference Include="Celly.Json" />
                    
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 Celly.Json --version 1.7.2
                    
#r "nuget: Celly.Json, 1.7.2"
                    
#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 Celly.Json@1.7.2
                    
#: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=Celly.Json&version=1.7.2
                    
Install as a Cake Addin
#tool nuget:?package=Celly.Json&version=1.7.2
                    
Install as a Cake Tool

Celly.Json Logo

Celly.Json

CI NuGet .NET 10 / .NET 11 License: MIT

High-performance, minimal-allocation System.Text.Json evaluation, JSON Schema / OpenAPI 3.0 static type checking, ASP.NET Core integration, and database query translation for Celly (Google Common Expression Language for .NET).

Packages

Package NuGet Dependencies Purpose
Celly.Json NuGet Celly + BCL Zero-eager-materialization System.Text.Json evaluation, JSON Schema / OpenAPI 3.0 static type checking, JsonLibrary, and direct CEL → JSON serialization
Celly.Json.AspNetCore NuGet Celly.Json + Microsoft.AspNetCore.App HttpContext activation, policy authorization, Minimal API CelFilter/CelOrderBy binders, RFC 9457 ProblemDetails, CelProgramCache, and OpenTelemetry metrics/tracing
Celly.Json.Query NuGet Celly.Json only (zero DB drivers) Parameterized CEL → SQL / JSON / MongoDB / IQueryable<T> (EF Core) translation, PostgreSQL jsonb GIN @> containment, AIP-160 ordering, CelQueryPolicy, and LRU caching
dotnet add package Celly.Json
dotnet add package Celly.Json.AspNetCore
dotnet add package Celly.Json.Query

Multi-targets .NET 10.0 (net10.0) and .NET 11.0 (net11.0, with Runtime Async enabled). Full NativeAOT and IL trimming support across all packages.


Features

Celly.Json — Core Evaluation, Schema Checking & Serialization

  • Zero eager materialization: Evaluates CEL directly over JsonElement, JsonDocument, JsonObject, and JsonArray without converting payloads to Dictionary<string, object?> / List<object?>.
  • Reusable activations & streaming: JsonElementActivation.Reset(...), JsonNodeActivation.Reset(...), FilterJsonArray, and FilterJsonLines (NDJSON streaming) with inline lookup caching.
  • Full ListValue integration: Zero-allocation in / == scans, list concatenation, optional indexing (arr[?0]), and comprehensions (all, exists, map, filter).
  • JSON Schema & OpenAPI 3.0 static type checking: JsonSchemaEnv.Create(...) / JsonSchemaTypeProvider support Draft-07, Draft 2020-12, and OpenAPI 3.0 (nullable: true, patternProperties with ReDoS-safe RegexOptions.NonBacktracking, dependentRequired, $ref/$defs, allOf/anyOf/oneOf, enum, additionalProperties, format mapping, and AOT-safe FromTypeInfo<T>).
  • Static cost estimation & JsonLibrary: Translates schema maxLength/maxItems/maxProperties into Celly ICostEstimator hints, and adds json.parse(string) / json.stringify(dyn) inside CEL.
  • Direct CEL → JSON serialization: CelJsonWriter.Write(...), ToJsonString(), ToUtf8JsonBytes(), and ToJsonNode().

Celly.Json.AspNetCore — ASP.NET Core & Minimal APIs

  • Minimal API query binders & ProblemDetails: Bind ?filter=... (CelFilter) and ?orderBy=... / ?order_by=... (CelOrderBy) directly in Minimal API handlers with automatic CelEnv schema type-checking, and attach .WithCelProblemDetails() for RFC 9457 400 Bad Request responses.
  • Authorization & endpoint filters: Express authorization policies and endpoint filters in CEL against request, user, claims, route, query, headers, and JSON request bodies via HttpContextActivation.
  • Caching & observability: Thread-safe lock-free-read LRU CelProgramCache with non-blocking background eviction and CellyAspNetCoreTelemetry (Meter + ActivitySource).

Celly.Json.Query — Database & LINQ Query Translation

  • Multi-dialect parameterized SQL & NoSQL: Translates CEL filter ASTs and AIP-160 orderBy clauses into parameterized queries for PostgreSQL jsonb (including opt-in GIN @> containment via CelQueryDialects.PostgresJsonbGin), SQL Server JSON, SQLite JSON, Azure Cosmos DB SQL, and MongoDB.
  • EF Core / IQueryable<T> pushdown: WhereCel, OrderByCel, and ThenByCel with fluent CelLinqMapping<T>, [CelPropertyName], and [CelIgnore] attributes.
  • Security & performance: CelQueryPolicy (field allowlists/denylists, max AST depth/nodes, disabled operators) and default lock-free-read LRU caching (CelQueryCache.Default).

Quick Start

1. Evaluate & Type-Check JSON (Celly.Json)

using System.Text.Json;
using Celly;
using Celly.Json;

CelEnv env = JsonSchemaEnv.Create("""
    {
      "type": "object",
      "properties": {
        "user": {
          "type": "object",
          "properties": {
            "age": { "type": "integer" },
            "roles": { "type": "array", "items": { "type": "string" } }
          }
        }
      }
    }
    """);

CelProgram program = env.Compile("user.age >= 18 && 'admin' in user.roles");

using JsonDocument doc = JsonDocument.Parse("""
    { "user": { "age": 32, "roles": ["viewer", "admin"] } }
    """);

// Lazy evaluation directly over JsonDocument (no Dictionary allocation)
bool allowed = program.EvalJsonBool(doc); // true

2. Minimal API Filtering, Ordering & ProblemDetails (Celly.Json.AspNetCore)

using Celly.Json.AspNetCore;
using Celly.Json.Query;

var api = app.MapGroup("/orders").WithCelProblemDetails();

api.MapGet("/", (CelFilter filter, CelOrderBy orderBy, CelQueryPolicy policy) =>
{
    var sql = filter.HasValue
        ? CelSqlQueryTranslator.Translate(filter.Ast!, CelQueryDialects.PostgresJsonbGin, policy: policy)
        : null;
    // Execute parameterized query with sql.WhereClause and sql.Parameters
    return Results.Ok(new { sql?.WhereClause, Clauses = orderBy.Clauses.Count });
});

3. Parameterized Database & LINQ Pushdown (Celly.Json.Query)

using Celly.Json.Query;

// PostgreSQL jsonb with GIN containment (@>)
CelSqlQuery pg = CelSqlQueryTranslator.Translate(
    "status == 'paid' && 'rush' in tags",
    CelQueryDialects.PostgresJsonbGin,
    rootSource: "data");
// pg.WhereClause => "((data @> CAST(@p0 AS jsonb)) AND (data @> CAST(@p1 AS jsonb)))"

// EF Core / IQueryable<T> filtering & AIP-160 ordering
IQueryable<Order> query = db.Orders
    .WhereCel("status == 'paid' && total >= 100")
    .OrderByCel("createdAt desc, id asc");

Benchmarks (.NET 10.0, BenchmarkDotNet MemoryDiagnoser)

Benchmark Mean Allocated vs. Naive Eager
Policy_NaiveEagerDictionary 19,375.4 ns 85,416 B Baseline
Policy_CellyJson_EvalJson 273.1 ns 504 B 71× faster, 169× less alloc
Policy_CellyJson_ReusableActivation 268.6 ns 384 B 72× faster, 222× less alloc
Policy_CellyJson_JsonObject 187.2 ns 296 B 103× faster, 288× less alloc
Comprehension100_NaiveEagerDictionary 55,508.1 ns 214,680 B Baseline
Comprehension100_CellyJson_ReusableActivation 8,503.5 ns 14,992 B 6.5× faster, 14.3× less alloc

Documentation

Build, Test & Benchmark

dotnet test -c Release --filter "Category!=Integration"
dotnet run --project benchmarks/Celly.Json.Benchmarks/Celly.Json.Benchmarks.csproj -c Release -f net10.0 -- --job short --filter "*"

License

Licensed under the MIT License.

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

  • net11.0

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Celly.Json:

Package Downloads
Celly.Json.Query

Zero-dependency CEL-to-database query translator: translates Celly ASTs into parameterized Cosmos DB NoSQL, PostgreSQL jsonb, SQL Server JSON, SQLite JSON, MongoDB filter queries, and EF Core / IQueryable LINQ expression trees.

Celly.Json.AspNetCore

ASP.NET Core integration for Celly.Json: lazy HttpContext CEL activations, authorization policies, Minimal API endpoint filters, compiled expression caching, and zero-copy Utf8JsonWriter IResult responses.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.7.2 45 12/2/2026
1.7.1 44 12/2/2026
1.7.0 62 12/1/2026
1.6.0 93 12/1/2026
1.5.1 101 11/30/2026
1.5.0 100 11/30/2026
1.4.0 103 11/30/2026
1.3.0 107 11/30/2026
1.2.0 108 11/29/2026
1.1.1 107 11/29/2026
1.1.0 103 11/29/2026
1.0.1 104 11/29/2026
1.0.0 99 11/29/2026
0.2.0 96 11/29/2026
0.1.0 99 11/29/2026