| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
This little code example shows how a Jsonnet config using object-oriented features can be transliterated (in a structure-preserving manner) to use the object-oriented features of Java. Not all Jsonnet programs can be converted to Java because Jsonnet has mixins and virtual inner classes. Execution order is also different, as Jsonnet is lazy and Java is eager. Likewise, Java programs cannot all be converted to Jsonnet because they have mutable state and I/O.
However said all this, there is a significant overlap between the two languages. This example fits within that overlap.
jsonnet sub-template.jsonnet
We pipe into jsonnet - to pretty-print the output JSON.
javac *.java && java Test | jsonnet -
The translation is as as follows:
The Java code has a number of auxiliary framework functions to provide Jsonnet functionality that is implicit in the Jsonnet language.
For reference, the JSON that should be output is given in sub-template.json
| Back | FazBrowse Home | New Git URL |