Skip to content

API Reference

github-actions[bot] edited this page Nov 29, 2026 · 2 revisions

API Reference

All public types live in the Celly.Json namespace.


Configuration

Type Description
CelJsonOptions Immutable options: NumberHandling, PropertyNameComparison, FieldFormats. Shared CelJsonOptions.Default.
CelJsonNumberHandling Int64IfWholeElseDouble (default), PreferInt64ThenUInt64ThenDouble, AlwaysDouble.
JsonStringFormat None, DateTime, Duration, Byte.
JsonSchemaOptions StrictObjectProperties (default true), MapFormats (default false). Shared JsonSchemaOptions.Default.

Evaluation & Activations

Type / Method Description
JsonElementActivation IActivation exposing root JsonElement object properties as CEL variables. Supports .Reset(JsonElement) and optional fallback activation.
JsonNodeActivation IActivation exposing root JsonObject properties as CEL variables. Supports .Reset(JsonObject) and optional fallback activation.
JsonVariableActivation IActivation binding a single JsonElement (any kind) to a named CEL variable. Supports .Reset(JsonElement).
JsonTypeAdapter ITypeAdapter that lazily adapts JsonElement, JsonDocument, and JsonNode, delegating all other types to an inner adapter (NativeTypeAdapter.Instance).
CelJsonValue.From(...) Factory helpers wrapping JsonElement, JsonDocument, or JsonNode? as a lazy CelValue.
program.EvalJson(...) Extension overloads for JsonElement, JsonDocument, JsonObject, string, and ReadOnlyMemory<byte>.
program.EvalJsonBool(...) Typed bool evaluation helper (throws CelEvaluationException on error or type mismatch).
program.EvalJsonInt64(...) Typed long evaluation helper.
program.EvalJsonDouble(...) Typed double evaluation helper.
program.EvalJsonString(...) Typed string evaluation helper.
value.AsBool() / AsInt64() / AsDouble() / AsString() Typed unwrapping helpers on CelValue.
predicate.FilterJsonArray(JsonElement) Lazily filters a JSON array of objects, reusing a single JsonElementActivation.
predicate.FilterJsonLines(Stream) Streams UTF-8 NDJSON, yielding detached JsonElement matches with a single reused activation.
CelEvaluationException Thrown by typed helpers on CEL ErrorValue or unexpected return type.

Lazy Value Wrappers

Type Description
JsonElementObjectValue Lazy CelValue over JsonElement (Object). Implements IStructValue, ISizedValue, IIndexerValue, IContainsTester, IIterableValue. Provides .Detach().
JsonElementListValue Lazy ListValue over JsonElement (Array). Provides .Detach() and zero-alloc IContainsTester.Contains.
JsonNodeObjectValue Lazy CelValue over JsonObject.
JsonNodeListValue Lazy ListValue over JsonArray.

JSON Schema & Cost Estimation

Type / Method Description
JsonSchemaEnv.Create(...) Creates a statically type-checked CelEnv from a JSON Schema string, JsonElement, JsonTypeInfo<T> (AOT-safe), or T.
JsonSchemaEnv.CreateForVariable(...) Same as Create, binding the schema to a single named CEL variable.
JsonSchemaTypeProvider ITypeProvider compiled from JSON Schema (FromJson, FromSchema, or AOT-safe FromTypeInfo<T>). Exposes RootType, RootDeclarations, CostEstimator, and CreateJsonOptions(...).
JsonSchemaCostEstimator ICostEstimator populated from JSON Schema maxLength/maxItems/maxProperties bounds. Supports .ForVariable(string).

Extension Library & Serialization

Type / Method Description
JsonLibrary.Instance / JsonLibrary.Create(...) CelLibrary adding json.parse(string) and json.stringify(dyn) inside CEL expressions.
CelJsonWriter.Write(Utf8JsonWriter, CelValue) Direct, minimal-allocation JSON serialization of any CelValue.
value.ToJsonString(JsonWriterOptions) Serializes a CelValue to a JSON string.
value.ToUtf8JsonBytes(JsonWriterOptions) Serializes a CelValue to UTF-8 JSON bytes.
value.ToJsonNode() Converts a CelValue into a JsonNode? DOM tree.

Clone this wiki locally