Celly.Json
1.7.2
dotnet add package Celly.Json --version 1.7.2
NuGet\Install-Package Celly.Json -Version 1.7.2
<PackageReference Include="Celly.Json" Version="1.7.2" />
<PackageVersion Include="Celly.Json" Version="1.7.2" />
<PackageReference Include="Celly.Json" />
paket add Celly.Json --version 1.7.2
#r "nuget: Celly.Json, 1.7.2"
#:package Celly.Json@1.7.2
#addin nuget:?package=Celly.Json&version=1.7.2
#tool nuget:?package=Celly.Json&version=1.7.2
![]()
Celly.Json
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
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, andJsonArraywithout converting payloads toDictionary<string, object?>/List<object?>. - Reusable activations & streaming:
JsonElementActivation.Reset(...),JsonNodeActivation.Reset(...),FilterJsonArray, andFilterJsonLines(NDJSON streaming) with inline lookup caching. - Full
ListValueintegration: Zero-allocationin/==scans, list concatenation, optional indexing (arr[?0]), and comprehensions (all,exists,map,filter). - JSON Schema & OpenAPI 3.0 static type checking:
JsonSchemaEnv.Create(...)/JsonSchemaTypeProvidersupport Draft-07, Draft 2020-12, and OpenAPI 3.0 (nullable: true,patternPropertieswith ReDoS-safeRegexOptions.NonBacktracking,dependentRequired,$ref/$defs,allOf/anyOf/oneOf,enum,additionalProperties,formatmapping, and AOT-safeFromTypeInfo<T>). - Static cost estimation &
JsonLibrary: Translates schemamaxLength/maxItems/maxPropertiesinto CellyICostEstimatorhints, and addsjson.parse(string)/json.stringify(dyn)inside CEL. - Direct CEL → JSON serialization:
CelJsonWriter.Write(...),ToJsonString(),ToUtf8JsonBytes(), andToJsonNode().
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 automaticCelEnvschema type-checking, and attach.WithCelProblemDetails()for RFC 9457400 Bad Requestresponses. - Authorization & endpoint filters: Express authorization policies and endpoint filters in CEL against
request,user,claims,route,query,headers, and JSON request bodies viaHttpContextActivation. - Caching & observability: Thread-safe lock-free-read LRU
CelProgramCachewith non-blocking background eviction andCellyAspNetCoreTelemetry(Meter+ActivitySource).
Celly.Json.Query — Database & LINQ Query Translation
- Multi-dialect parameterized SQL & NoSQL: Translates CEL filter ASTs and AIP-160
orderByclauses into parameterized queries for PostgreSQLjsonb(including opt-in GIN@>containment viaCelQueryDialects.PostgresJsonbGin), SQL Server JSON, SQLite JSON, Azure Cosmos DB SQL, and MongoDB. - EF Core /
IQueryable<T>pushdown:WhereCel,OrderByCel, andThenByCelwith fluentCelLinqMapping<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
- Full user guides, examples, and API reference: Celly.Json Wiki
- Release history: CHANGELOG.md
- Planned work: ROADMAP.md
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 | Versions 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. |
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 |