Giter Site home page Giter Site logo

jsonsql4j's Introduction

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

jsonsql4j's People

Contributors

eaxdev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

jsonsql4j's Issues

Implement SELECT support

Need transfom Json string like this:

{
  "fields": [
    {"column": "field1"},
    {"column": "field2", "alias": "test"}
  ],
  "from": [
    {"table": "table1", "schema": "schema"}
  ]
}

to SELECT query.

In this task add JOIN and Criteria support.

Support for simple IN operator

Do you have any plan to support simple IN operator ?
I see that this library is still a work in progress.

Have you considered adding IN operator support ?
A simple IN operator dealing with string,long,double values would be a great addition.

example,

IN('US','UK','IN','NZ')

IN(1,2,3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.