JsonifySQL 0.8.0
Suggested Alternatives
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package JsonifySQL --version 0.8.0
NuGet\Install-Package JsonifySQL -Version 0.8.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="JsonifySQL" Version="0.8.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="JsonifySQL" Version="0.8.0" />
<PackageReference Include="JsonifySQL" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add JsonifySQL --version 0.8.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: JsonifySQL, 0.8.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package JsonifySQL@0.8.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=JsonifySQL&version=0.8.0
#tool nuget:?package=JsonifySQL&version=0.8.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
JsonifySQL
JsonifySQL is a .NET library that allows querying data through a structured JSON request format. It provides flexible filtering, ordering, pagination, and schema discovery capabilities, making it easy to build dynamic, data-driven APIs.
๐ฆ Installation
Install via NuGet Package Manager:
Install-Package JsonifySQL
Or via .NET CLI:
dotnet add package JsonifySQL
โจ Features
- ๐ Query data using a powerful and intuitive JSON format
- ๐งพ Discover available schemas via schema requests
- ๐ Join related data with configurable relationships
- ๐ Apply dynamic filters and ordering
- ๐ Use aggregation functions (sum, avg, min, max)
- ๐ Support for both offset and cursor-based pagination
- ๐ฅ Profile-based access control to queryable objects
- Currently only supporting postgresql parser
โ๏ธ Configuration
Define searchable objects using a jsonifysql.conf
file:
{
"clients": {
"alias": "c",
"visibleOnSchemaQuery": true,
"cursorField": {
"name": "cid",
"type": "integer"
},
"fields": {
"cid": { "type": "integer", "description": "Client identifier" },
"name": { "type": "string", "description": "Name of the client" }
},
"relations": {
"docs": { "joinField": "cid", "onField": "cid" }
},
"fixedOrderBy": {
"cid": "ASC"
},
"access": ["Admin", "DefaultUser"]
}
}
Optional elements: relations
, fixedConditions
, fixedMerges
, fixedOrderBy
, and forProfile
.
Notes: build the jsonifysql.conf file as content.
๐ Usage
1. Register Services
In your Startup.cs
or Program.cs
:
builder.Services.AddJsonifySQL("jsonifysql.conf");
builder.Services.AddScoped<IJsonifySQLParser, PostgresJsonifySQL>(); // For PostgreSQL
2. Inject and Use the Parser
public class MySearch
{
private readonly IJsonifySQLParser _jsonifyParser;
public MySearch(IJsonifySQLParser jsonifySQLParser)
{
_jsonifyParser = jsonifySQLParser;
}
public async Task<object> DoSearch(string jsonQuery)
{
object? finalResult = null;
var parserResult = _jsonifyParser.ParseJsonQuery(jsonQuery, profile: userProfile, parameterValues: parameters);
if (!parserResult.Success)
return parserResult.ParseStatusMessage;
if (parserResult.IsDataQuery)
{
// Execute raw SQL: parserResult.FinalQuery & parserResult.PaginationQuery
// if using dapper, you can use the query multiple function and execute the two statements
}
if (parserResult.IsSchemaQuery)
{
finalResult = JsonSerializer.Deserialize<object>(parserResult.SchemaResponse, new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
WriteIndented = true
});
}
return finalResult;
}
}
๐ Example JSON Requests
Simple Query
{
"query": {
"clients": {
"select": ["cid", "name"]
}
}
}
With Filter
{
"query": {
"clients": {
"select": ["cid", "name"],
"where": {
"name": { "ct": "John" }
}
}
}
}
With Pagination
Cursor-based:
{
"query": {
"clients": {
"select": ["cid", "name"]
},
"page": {
"size": 100,
"after": "cursorvalue"
}
}
}
Offset-based:
{
"query": {
"clients": {
"select": ["cid", "name"]
},
"page": {
"size": 100,
"current": "1"
}
}
}
With Ordering
{
"query": {
"clients": {
"select": ["cid", "name"],
"orderBy": {
"name": "ASC"
}
}
}
}
Schema Request
{
"schema": {}
}
๐ Supported Operators
Comparison Operators
Operator | Meaning |
---|---|
eq |
Equals to |
neq |
Not equals to |
gt |
Greater than |
lt |
Less than |
gte |
Greater or equal to |
lte |
Less or equal to |
sw |
Starts with |
ew |
Ends with |
ct |
Contains |
in |
In |
matches |
Full-text match (vector fields only) |
Logical Operators
and
or
Aggregation Functions
sum
min
max
avg
count
๐ License
This project is licensed under the MIT License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.