0

I am new to using Jsonnet and I am trying to create a configuration file using sjsonnet by DataBricks in a Java codebase. The README on their Github Repo explains how to use Jsonnet without external variables, which is as follows:

// JsonnetRunner.java
...
int res = sjsonnet.SjsonnetMain.main0(
    new String[]{"foo.jsonnet"},
    new DefaultParseCache,
    System.in,
    System.out,
    System.err,
    os.package$.MODULE$.pwd(),
    scala.None$.empty()
);
...

I want to run a Jsonnet file that takes in two --ext-str arguments. I am able to do this by running jsonnet --ext-str "var1=Foo" --ext-str "var2=Bar" using the official Jsonnet implementation, and as ./sjsonnet.jar --ext-str "var1=Foo" --ext-str "var2=Bar" using the Sjsonnet JAR. My question is: how can I implement this in my Java code? Additionally, I would like to get the JSON string once the Jsonnet execution finishes instead of getting it on the output.

Thank you in advance!

Anuran Roy
  • 1
  • 1
  • 3

0 Answers0