JsonSQL4J

Generate SQL queries from JSON strings

License

License

Categories

Categories

JSON Data
GroupId

GroupId

io.github.eaxdev
ArtifactId

ArtifactId

jsonsql4j
Last Version

Last Version

0.0.3
Release Date

Release Date

Type

Type

pom.sha512
Description

Description

JsonSQL4J
Generate SQL queries from JSON strings
Project URL

Project URL

https://github.com/eaxdev/JsonSQL4J
Project Organization

Project Organization

com.github.eaxdev
Source Code Management

Source Code Management

https://github.com/eaxdev/JsonSQL4J

Download jsonsql4j

Dependencies

compile (1)

Group / Artifact Type Version
com.fasterxml.jackson.core : jackson-databind jar 2.10.1

runtime (1)

Group / Artifact Type Version
org.projectlombok : lombok jar 1.18.10

Project Modules

There are no modules declared in this project.

JsonSQL4J

Build Status GitHub license Maven Central codecov Quality Gate Status

This library for mapping JSON style query objects to SQL queries

Get it!

Maven

You can use following Maven dependency:

<dependency>
  <groupId>io.github.eaxdev</groupId>
  <artifactId>jsonsql4j</artifactId>
  <version>0.0.2</version>
</dependency>

Gradle

implementation 'io.github.eaxdev:jsonsql4j:0.0.2'

Also, you can use GitHub Packages.

Use it!

Given JSON:

{
  "fields": [
    {"column": "field1"},
    {"column": "field2", "alias": "test"}
  ],
  "from": [
    {"table": "table1", "schema": "schema"}
  ],
  "where": {
    "or": [
      { "eq": {"fieldName": "field3", "value": "5"} },
      { "eq": {"fieldName": "field4", "value": "3"} }
    ]
  }
}

use library:

Query selectQuery = new SelectQuery(jsonString);
String query = selectQuery.getQuery();
// query = SELECT field1, field2 AS test FROM schema.table1 WHERE (field3 = 5 OR field4 = 3)

You can find more examples here.

License

JsonSQL4J is open-source project, and distributed under the MIT license

Versions

Version
0.0.3
0.0.2
0.0.1