Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

eaxdev/JsonSQL4J

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.3</version>
</dependency>

Gradle

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

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

About

Generate SQL queries from JSON strings

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.