This Java interpreter is based on the MODL Specification.
There are several ways the interpreter can be used:
- Using the MODL Playground
- Writing a Java program
- Building and running on the command line
First clone the repository and build the project using gradle clean customFatJar
from the project root directory.
Create a file containing a MODL object, e.g. test.modl
with:
a=test;
b=123;
c=Hello World
Run the interpreter using the command:
java -jar ./build/libs/interpreter-<version>.jar test.modl
The result should be:
Processing file: test.modl
{
"a" : "test",
"b" : 123,
"c" : "Hello World"
}
Finished file: test.modl
Multiple file names can be provided if needed, and the value of $?
is the number of files that errored, so 0
is success.
The Interpreter
class has several convenience methods, each returning a slightly different result depending on how the result is to be further processed.
Convert a MODL String to a JSON String:
final String json = Interpreter.interpretToJsonString("a=b");
Use this method to generate a compact JSON
String.
Convert a MODL String to a pretty-printed JSON String:
final String json = Interpreter.interpretToPrettyJsonString("a=b");
Use this method to generate a JSON
String for easy reading.
Convert a MODL String to a JsonNode
:
final JsonNode jsonNode = Interpreter.interpretToJsonObject("a=b");
Use this method to generate non-proprietary object for further processing.
Convert a MODL String to a Modl
object:
final Modl modl = Interpreter.interpret("a=b");
Use this method to generate an object using the core model within the library, i.e. those in the uk.modl.model
package.
We have a version of the interpreter in Ruby, and a JavaScript version.
Bugs and New feature requests should be raised as GitHub issues, and the community is welcome to fork the repository and submit pull requests.