Path: redb-route/redb.Route.JsonTransform/JsonTransformRouteDefinitionExtensions.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.JsonTransform/JsonTransformRouteDefinitionExtensions.cs ---- using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using redb.Route.Abstractions; using redb.Route.Core; namespace redb.Route.JsonTransform; /// /// DSL of the JSON transform step. A string argument is a locator (file relative to /// , or assembly:Name/path); an inline /// specification is TextSource.Inline("..."). /// /// /// .TransformJson("Transforms/order-to-shipment.jsonata") /// .TransformJson(TextSource.Inline("{ 'id': orderId, 'to': { 'city': address.city }, 'tenant': $headers.tenant }")) /// .TransformJson("Transforms/x.jsonata", JsonTransformOutput.Node) /// /// /// public static class JsonTransformRouteDefinitionExtensions { /// Applies the JSONata specification at to the JSON body. public static IRouteDefinition TransformJson(this IRouteDefinition route, string locator, JsonTransformOutput output = JsonTransformOutput.String) => TransformJson(route, TextSource.FromLocator(locator), output); /// Applies the JSONata specification to the JSON body. public static IRouteDefinition TransformJson(this IRouteDefinition route, TextSource specification, JsonTransformOutput output = JsonTransformOutput.String) { ArgumentNullException.ThrowIfNull(route); var definition = new JsonTransformDefinition(specification, output) { Parent = route }; route.Outputs.Add(definition); // the public tree API, identical to ProcessorDefinition.AddOutput return route; } /// DI registration: services.AddJsonTransform(o => o.BaseDirectory = "/etc/acme/transforms"). public static IServiceCollection AddJsonTransform(this IServiceCollection services, Action? configure = null) { ArgumentNullException.ThrowIfNull(services); var options = new JsonTransformOptions(); configure?.Invoke(options); services.TryAddSingleton(options); return services; } /// Registration on a context built without DI: context.UseJsonTransform(o => o.Indent = true). public static IRouteContext UseJsonTransform(this IRouteContext context, Action? configure = null) { ArgumentNullException.ThrowIfNull(context); var options = new JsonTransformOptions(); configure?.Invoke(options); context.AddService(typeof(JsonTransformOptions), options); return context; } }