k6 jsonnet extension.
import jsonnet from 'k6/x/jsonnet';
export default function () {
const jsonnetTemplate = '{ "hello": "world" }';
const jsonStr = jsonnet.evaluateJsonnet(jsonnetTemplate);
console.log(jsonStr);
}
- evaluateJsonnet(
jsonnetTemplate
: string): string- It will take
jsonnet
template string and returnjson
object string after evaluate the template.
- It will take
To build a k6
binary with this extension, first ensure you have the prerequisites:
Then:
- Install xk6:
go install go.k6.io/xk6/cmd/xk6@latest
- Build the binary:
# specific tag version xk6 build --with github.com/VikashChauhan51/k6-jsonnet@v0.1.0 or # latest version xk6 build --with github.com/VikashChauhan51/k6-jsonnet@latest
./k6 run examples/main.js