Questions tagged [jsonnet]

Jsonnet is a data templating language which compiles to JSON.

Jsonnet is a domain specific configuration language that helps you define JSON data. Jsonnet lets you compute fragments of JSON within the structure, bringing the same benefit to structured data that templating languages bring to plain text.

Project info

116 questions
0
votes
2 answers

How do I access all the fields of an imported object?

$ cat foo.libsonnet { local foo = 99, bar: [ foo, 101 ] } $ cat baz.jsonnet { local foo = import 'foo.libsonnet', baz: [foo.foo, foo.bar] } $ jsonnet baz.jsonnet RUNTIME ERROR: field does not exist: foo baz.jsonnet:3:11-18 …
John Schmitt
  • 1,148
  • 17
  • 39
0
votes
1 answer

Substitute array to jsonnet

I have a jsonnet file local version = std.extVar('version'); local entities = std.extVar('entities'); { appname::'app-dev', version::version, entities::entities, } The version field seems to be a string, but "entities" field is an…
Uladzislau Kaminski
  • 2,113
  • 2
  • 14
  • 33
0
votes
1 answer

Extending inner object without explicitly extending every object in its path

I have the following 2 files: 1.jsonnet { a: { b: { b1: 1 } } } 2.jsonnet local one = import'1.jsonnet'; one { a+: { b+: { b2: 2 } } } I want to extend the inner object b which is part of a (e.g. add a.b.b2),…
0
votes
1 answer

Generating JSON config files from permutation of set of object values

I'm trying to create a set of JSON configuration files for my program. I generally pass a JSON file to the command line and run my simulation. The issue is that I want to explore a lot parameters and I want to create a config files for each set of…
Amir
  • 1,087
  • 1
  • 9
  • 26
0
votes
1 answer

How to embed a literal json within a YAML using jsonnet?

Here's what I'm trying to achieve using jsonnet: version: "v1" data: j.json: |- { "foo": "bar" } Here's my failed attempt: local j = { foo: "bar" }; local wrapper = { version: "v1", data: { 'j.json': ||| j ||| …
Maklaus
  • 538
  • 2
  • 16
  • 37
0
votes
2 answers

Inheritance with jsonnet libraries

I have a question about the import functionality of JSONNet. What I would like is to be able to import one master libsonnet file, which itself is composed of multiple imports, and be able to access everything from that one import. I have the…
Scott Crooks
  • 1,523
  • 4
  • 24
  • 39
0
votes
2 answers

import with conditional argument in jsonnet

I would like to have the ability to specify different arguments to the imported variable and change the behaviour of import. For example, I would like to have something like the following: local foo = import "foo.libsonnet"; { "foo1": foo["foo1"],…
Ali
  • 1,759
  • 2
  • 32
  • 69
0
votes
1 answer

How to override 'self' in Jsonnet?

I am trying to create a template which has some defaults but these should be overridden if a custom values file is provided. The problem is some of my variables in the object are built from other variables in the same object, like adjective: 'Good'…
0
votes
1 answer

Custom builtin functions in jsonnet

Is there a way how I can call golang functions from jsonnet? Now that there is a go port of jsonnet and for example ksonnet is adding custom native functions I am wondering if there is a way how to extend jsonnet with more native functions? I have…
Aleš
  • 8,896
  • 8
  • 62
  • 107
0
votes
1 answer

Convert chinese to unicode

i use jsonnet tool to convert json "{a:\"李\"}" result is { "name": "\u00c0\u00ee" } why chinese is convert to two Unicode?
Eric
  • 1
  • 1
-1
votes
1 answer

a way to convert json files into jsonnet files?

is there a way to convert json files into jsonnet files? I am working on grafana dashboards as code and need to convert a json file into jsonnet. Or is there a good guide on how to create panels in Grfana except the official Jsonnet website? I would…
M65
  • 27
  • 3
1 2 3 4 5 6 7
8