Skip to content
Golang CGo Wrapper around JSonnet VM
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
jsonnet_main Quote illegal argv value, in error log.Fatalf. May 24, 2017
stress_loop Forgot to call flag.Parse() in stress_loop. Jul 7, 2017
.gitignore
CHECK-TESTS.sh CHECK-TESTS.sh to run tests from google/jsonnet. Mar 10, 2019
COMPARE-jsonnet.sh Update to v0.12.1 Dec 27, 2018
LICENSE
LICENSE.json
LICENSE.jsonnet Embed jsonnet sources Mar 1, 2017
LICENSE.md5 License for the MD5 code. Apr 18, 2017
README.md Add command line examples to the README. Dec 27, 2018
ast.h Update to LIB_JSONNET_VERSION "v0.10.0" Mar 17, 2018
bridge.c Add support for native functions as go callbacks Jun 16, 2017
desugarer.cpp Update C version "v0.12.1" to "v0.13.0" Jul 4, 2019
desugarer.h Embed jsonnet sources Mar 1, 2017
formatter.cpp Update to C version v0.11.2 Oct 12, 2018
formatter.h Update to LIB_JSONNET_VERSION "v0.10.0" Mar 17, 2018
json.h Update to LIB_JSONNET_VERSION "v0.10.0" Mar 17, 2018
json.hpp Update C version "v0.12.1" to "v0.13.0" Jul 4, 2019
jsonnet.go Update to v0.12.1 Dec 27, 2018
jsonnet_test.go Update to LIB_JSONNET_VERSION "v0.10.0" Mar 17, 2018
lexer.cpp Update to C version v0.11.2 Oct 12, 2018
lexer.h Update to LIB_JSONNET_VERSION "v0.10.0" Mar 17, 2018
libjsonnet.cpp
libjsonnet.h Update C version "v0.12.1" to "v0.13.0" Jul 4, 2019
libjsonnet_fmt.h Update to v0.12.1 Dec 27, 2018
md5.cpp Update to LIB_JSONNET_VERSION "v0.10.0" Mar 17, 2018
md5.h Embed jsonnet sources Mar 1, 2017
parser.cpp Update to LIB_JSONNET_VERSION "v0.10.0" Mar 17, 2018
parser.h
pass.cpp
pass.h Update to LIB_JSONNET_VERSION "v0.10.0" Mar 17, 2018
state.h Update to C version v0.11.2 Oct 12, 2018
static_analysis.cpp Update to LIB_JSONNET_VERSION "v0.10.0" Mar 17, 2018
static_analysis.h Embed jsonnet sources Mar 1, 2017
static_error.h Update to LIB_JSONNET_VERSION "v0.10.0" Mar 17, 2018
std.jsonnet.h Update C version "v0.12.1" to "v0.13.0" Jul 4, 2019
string_utils.cpp Update to LIB_JSONNET_VERSION "v0.10.0" Mar 17, 2018
string_utils.h Update to LIB_JSONNET_VERSION "v0.10.0" Mar 17, 2018
test1.j
test2.j I think it works. Jan 8, 2015
unicode.h Update to LIB_JSONNET_VERSION "v0.10.0" Mar 17, 2018
vm.cpp Update C version "v0.12.1" to "v0.13.0" Jul 4, 2019
vm.h Update to LIB_JSONNET_VERSION "v0.10.0" Mar 17, 2018

README.md

jsonnet_cgo

Simple golang cgo wrapper around JSonnet VM.

Everything in libjsonnet.h is covered except the multi-file evaluators.

See jsonnet_test.go for how to use it.

Quick example in golang:

    vm := jsonnet.Make()
    vm.ExtVar("color", "purple")

    x, err := vm.EvaluateSnippet(`Test_Demo`, `"dark " + std.extVar("color")`)

    if err != nil {
            panic(err)
    }
    if x != "\"dark purple\"\n" {
            panic("fail: we got " + x)
    }

    vm.Destroy()

Quick examples with the command line demo program:

$ ( cd jsonnet_main/  ; go  build -x -a )
...
mv $WORK/b001/exe/a.out jsonnet_main
...
$ echo "{ a: 1, b: 2 }"  | jsonnet_main/jsonnet_main /dev/stdin
{
   "a": 1,
   "b": 2
}
$ cat test1.j
{
  shell: "/bin/sh",
  awk: "/usr/bin/awk",
}
$ jsonnet_main/jsonnet_main test1.j
{
   "awk": "/usr/bin/awk",
   "shell": "/bin/sh"
}
$ cat test2.j
local test1 = import "test1.j";

test1 {
  shell: "/bin/csh",
}
$ jsonnet_main/jsonnet_main test2.j
{
   "awk": "/usr/bin/awk",
   "shell": "/bin/csh"
}
$ echo ' std.extVar("a") + "bar" ' | jsonnet_main/jsonnet_main /dev/stdin a=foo
"foobar"

LICENSES

Notice the various LICENSE* files. I cannot offer legal advice, but you might find that the Apache License is the most restrictive.

Most of this code comes from https://github.com/google/jsonnet and is under the Apache License, Version 2.0, January 2004, and our files that match filenames there are under that license.

Notice the third_party/ directory in that distribution. It has json/ and md5/ under their own licences, and our files that match filenames there are under those licenses.

Anything new added here is under an MIT license in the plain LICENSE file.

You can’t perform that action at this time.