Install
| Product | Versions |
|---|---|
| .NET |
README
Neuroglia.Data.Expressions.JQ
A .NET package to evaluate expressions using jq. This library integrates jq with .NET applications, making it simple to work with JSON data transformations and expressions.
Getting Started
Installation
- Add the package to your .NET project:
dotnet add package Neuroglia.Data.Expressions.JQ
- Ensure
jqis installed:
apt-get update
apt-get install jq -y
For other systems, refer to the official jq installation guide.
Configuration
Optionally, configure the JQ Expression Evaluator in your application's Dependency Injection (DI) container:
services.AddJQExpressionEvaluator(options =>
{
options.UseSerializer<MyJsonSerializerImplementation>(); // Optional: Defaults to the first registered `IJsonSerializer`
}, ServiceLifetime.Singleton);
Usage
After setup, you can start using the evaluator to process expressions.
Example Code
var defaultEvaluator = serviceProvider.GetRequiredService<IExpressionEvaluator>();
var explicitEvaluator = serviceProvider.GetRequiredService<IExpressionEvaluatorProvider>().GetEvaluator("jq");
var expression = "{ \"foo\": .foo, \"bar\": $param1.bar }";
var input = new
{
foo = "bar"
};
var arguments = new Dictionary<string, object>()
{
{
"param1",
new
{
bar = "baz"
}
}
};
var result = await defaultEvaluator.EvaluateAsync(expression, input, arguments, typeof(MyResult));
public class MyResult
{
public string Foo { get; set; }
public string Bar { get; set; }
}
Features
- Easily integrate the
jqtool with .NET applications. - Support for Dependency Injection with customizable options.
- Strongly-typed evaluation for JSON transformation.
- Flexible serialization options.
Requirements
- .NET Version: Compatible with .NET 9+.
- jq: Ensure
jqis installed on your system.
Contributing
Feel free to contribute to this project! Please submit issues, feature requests, or pull requests on the GitHub repository.
License
This project is licensed under the Apache 2.0 license.
Changes from Previous Version
Adoption Assessment
A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.