JsonifySQL 0.7.0
See the version list below for details.
dotnet add package JsonifySQL --version 0.7.0
NuGet\Install-Package JsonifySQL -Version 0.7.0
<PackageReference Include="JsonifySQL" Version="0.7.0" />
<PackageVersion Include="JsonifySQL" Version="0.7.0" />
<PackageReference Include="JsonifySQL" />
paket add JsonifySQL --version 0.7.0
#r "nuget: JsonifySQL, 0.7.0"
#:package JsonifySQL@0.7.0
#addin nuget:?package=JsonifySQL&version=0.7.0
#tool nuget:?package=JsonifySQL&version=0.7.0
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
โ๏ธ 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
.
๐ Usage
1. Register Services
In your Startup.cs
or Program.cs
:
builder.Services.AddJsonifySQL("path to the jsonifysql.conf file");
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
๐ 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. |
-
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.