JsonToLinq 1.0.0-rc911
See the version list below for details.
dotnet add package JsonToLinq --version 1.0.0-rc911
NuGet\Install-Package JsonToLinq -Version 1.0.0-rc911
<PackageReference Include="JsonToLinq" Version="1.0.0-rc911" />
<PackageVersion Include="JsonToLinq" Version="1.0.0-rc911" />
<PackageReference Include="JsonToLinq" />
paket add JsonToLinq --version 1.0.0-rc911
#r "nuget: JsonToLinq, 1.0.0-rc911"
#:package JsonToLinq@1.0.0-rc911
#addin nuget:?package=JsonToLinq&version=1.0.0-rc911&prerelease
#tool nuget:?package=JsonToLinq&version=1.0.0-rc911&prerelease
JsonToLinq
JsonToLinq - lightweight C# library that converts JSON-based query definitions into LINQ expressions. Ideal for building dynamic filters, predicates, and queries.
๐ฏ Use Cases
JsonToLinq can be applied in various scenarios where dynamic, runtime-defined queries are needed. Examples include:
- Server-side filtering: Apply JSON-defined filters received from front-end applications to collections or database queries.
- Dynamic reporting: Build complex filters and predicates for reports without hardcoding logic.
- Custom dashboards: Let users define queries for dashboards dynamically and translate them to LINQ expressions.
- EF Core / Entity Framework queries: Map JSON filters directly to LINQ queries executed on the database.
- Audit & logging filters: Dynamically select subsets of data based on JSON rules for auditing or logging purposes.
๐ Quick Start
using Neomaster.JsonToLinq;
var users = source.Where(
"""
{
"Logic": "&&",
"Rules": [
{
"Field": "balance",
"Operator": "=",
"Value": 0
},
{
"Logic": "||",
"Rules": [
{
"Field": "lastVisitAt",
"Operator": "=",
"Value": null
},
{
"Field": "lastVisitAt",
"Operator": "<=",
"Value": "2025-01-01T00:00:00Z"
}
]
}
]
}
""");
๐ ๏ธ Operators
๐ Operators and their handling logic are encapsulated in class ExpressionOperatorMapper.
The default operator mapping can be accessed via property Pairs.
๐ String comparisons are case-sensitive, depending on the database collation, not on the operators.
๐ Default Operators
| JSON | LINQ Expression | Description |
|---|---|---|
& |
Expression.And |
Bitwise AND |
&& |
Expression.AndAlso |
Logical AND |
| |
Expression.Or |
Bitwise OR |
|| |
Expression.OrElse |
Logical OR |
= |
Expression.Equal |
Equal |
!= |
Expression.NotEqual |
Not equal |
> |
Expression.GreaterThan |
Greater than |
>= |
Expression.GreaterThanOrEqual |
Greater than or equal |
< |
Expression.LessThan |
Less than |
<= |
Expression.LessThanOrEqual |
Less than or equal |
in |
ExpressionOperators.In |
In collection |
๐ Add Custom Operators
JsonLinq.Configure(options =>
{
options.OperatorMapper
.Add("lt", Expression.LessThan)
.Add("gt", Expression.GreaterThan);
});
๐ฌ Demos and Experiments
This repository contains a project with working examples. You are welcome to submit a PR with your own examples, bug reports, or new features. To describe a filter, use the following notation:
๐ค Filter Notation
Syntax
expr = logic[expr(, expr)*]
expr- a single rule or a combination of ruleslogic- an operator used to combine multiple rules, e.g.&&,&,||,|, or a custom one
Examples
&&[x = null]&&[a < 0, b > 0]&&[x = null, ||[a < 0, b > 0]]
๐ป Demo Project
This project provides examples of working with EF Core and a PostgreSQL database.
๐งช A real database is used instead of in-memory storage, ensuring clean and realistic experiments.
โ You can add your own examples with other databases or ORMs via a PR.
โถ๏ธ Before running the demos, select the first menu item, Prepare Data, to apply migrations and populate the tables with test data.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- System.Text.Json (>= 9.0.10)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 140 | 1/3/2026 |
| 1.0.0-rc923 | 188 | 1/2/2026 |
| 1.0.0-rc922 | 114 | 1/2/2026 |
| 1.0.0-rc921 | 114 | 1/2/2026 |
| 1.0.0-rc920 | 114 | 1/2/2026 |
| 1.0.0-rc918 | 110 | 1/2/2026 |
| 1.0.0-rc917 | 115 | 1/2/2026 |
| 1.0.0-rc916 | 149 | 12/20/2025 |
| 1.0.0-rc915 | 153 | 12/20/2025 |
| 1.0.0-rc914 | 196 | 12/19/2025 |
| 1.0.0-rc913 | 259 | 12/19/2025 |
| 1.0.0-rc912 | 262 | 12/19/2025 |
| 1.0.0-rc911 | 286 | 12/18/2025 |
| 1.0.0-rc910 | 297 | 12/17/2025 |
| 1.0.0-rc909 | 285 | 12/17/2025 |
| 1.0.0-rc908 | 139 | 12/13/2025 |
| 1.0.0-rc907 | 141 | 12/13/2025 |
| 1.0.0-rc906 | 140 | 12/12/2025 |
| 1.0.0-rc905 | 429 | 12/11/2025 |
| 1.0.0-rc904 | 468 | 12/9/2025 |