Coder Social home page Coder Social logo

json-logic-java's Introduction

json-logic-java

A Java implementation of http://jsonlogic.com/

Maven

A maven release has not yet been made as the library is still under development

<dependencies>
  <dependency>
    <groupId>com.northernwall</groupId>
    <artifactId>json-logic-java</artifactId>
    <version>1.0.0</version>
    <type>jar</type>
  </dependency>
</dependencies>

Usage

One Time Evaluation

String rule = "{\"cat\": [\"I love \", {\"var\":\"filling\"}, \" pie"\]}";
String data = "{"filling":"apple", "temp":110}";
Result result = jsonLogic.apply(rule, data);

Reuse A Rule With different data

String rule = "{\"cat\": [\"I love \", {\"var\":\"filling\"}, \" pie"\]}";
JsonLogicTree tree = jsonLogic.parse(rule);

Result result1 = tree.evaluate("{"filling":"apple", "temp":110}");
Result result2 = tree.evaluate("{"filling":"blueberry", "temp":120}");
Result result3 = tree.evaluate("{"filling":"key lime", "temp":115}");

Tests

There are 95 test cases that are contained within the file "BulkTests.txt". Some of the test cases are from http://jsonlogic.com/operations.html while other I wrote. Each line in the file represents a test or a comment. Each line has 2 or 3 components sperated by a tab. The first component is the JsonLogic expression, the second (optional) component is the JSON data object, and the last component is the expected result.

Current 48 tests are failing, 47 tests are passing, of 95 total tests. The failing tests largely represent operations that have not yet been coded for. When all test cases pass intend to release the first version of json-logic-java

json-logic-java's People

Contributors

jukkorsis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

json-logic-java's Issues

combo of == and dotnotation is not working?

I just tried the below line with your junit framework
{"==" : [ { "var" : "code" }, "ER"]} {"code": "ER", "name": "Exploratory Research"} true
I see the error " Error on line 2 - result is null"
Am I doing something wrong? Please help

Maven build yet to come?

I see a great effort out there on java implementation of jsonlogic. Can you please let me know if you are almost there to release the first version?

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.