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
1 answer

Conditionally creating a massive object, generated by several for loops?

I have some condition, if it is satisfied I've to create a massive object and merge it into the other one (at least that's how I understand jsonnet works in general): local something_something = true; local tst = { n1: { a: "10.172.52.0/22", …
NarūnasK
  • 4,564
  • 8
  • 50
  • 76
0
votes
1 answer

What is the jsonnet syntax for nested arrays?

I cannot find the way to declare an array in an array with jsonnet. Here is the syntax I would like to render: git/push/myrules: rules: - changes: - package.json - yarn.lock I do succeed to setup changes as the first element…
Richard
  • 23
  • 3
0
votes
1 answer

Tanka/Jsonnet import in parentheses

I've started to play with the Tanka and can't find anywhere the answer to the question: What is difference between (import "my.jsonnet") and import "my.jsonnet" and why the following construction is valid: (import "my.jsonnet") + (import…
0
votes
1 answer

jsonnet - output multiple files from seed array

Just getting started with jsonnet. My goal is to generate multiple json files from template json and seed array. I've seen that you can use for syntax to iterate and also the the Multiple File Output section under the Getting Started but not how to…
Chris Moutray
  • 18,029
  • 7
  • 45
  • 66
0
votes
1 answer

How to access a response value titled "self"?

I am using jsonnet to process a response that is structured like so: { "resources": [ { "response_body": { "id": "test_id", "key": "test_key", "self":…
Abe Miessler
  • 82,532
  • 99
  • 305
  • 486
0
votes
2 answers

How to Install JSONNET tools on Windows-10?

I need to use this library since its a project requirements. I am referring to official release website : https://jsonnet.org/learning/tools.html But sadly no way find out for installation on Windows. Need help for this topic. Thanks in advance !
0
votes
1 answer

How to get all subdirectories in jsonnet?

I'm creating a gitlab-ci.yml file dynamically with jsonnet. Now I want to create a job for each directory in my customers-directory. For that I want to read all directory names into an array. How do I do that? Pseudo code would look like…
0
votes
1 answer

jsonnet expression to string before evaluation

Given the following jsonnetfile: { expression: self.result, result: 3 > 1, } That evaluates to this: { "expression": true, "result": true } Is there a way to convert the expression to string before evaluation? The desired result would be…
hillsprig
  • 307
  • 5
  • 12
0
votes
1 answer

How to access a variable in Jsonnet if it's in a nested dictionary?

My goal is to make values of inner fields accessible to outer fields in a nested dictionary. Let's say I have the following code diction: { "outer": "part1", { "inner": "part2" } "outer and inner": outer + inner } The above code…
Ambitious Intern
  • 311
  • 1
  • 3
  • 13
0
votes
1 answer

Replace value in nested YAML with Jsonnet

Let's say I have the following YAML and I'd like to replace 'samsung' with 'apple' how do I do this in jsonnet? I could not find any way doing this and I'm searching for the solution since hours. products: - smartphones: - samsung computers: -…
newduino
  • 179
  • 1
  • 6
  • 16
0
votes
1 answer

jsonnet std.map - "attempted to index array with string name" error

i am new to jsonnet I am trying to call the name and nb seperately for different operations. But i am getting error "attempted to index array with string name" when i use "specificValues.data.LIST.name" in the code. local NbMap = { ABC: 1, XYZ:…
Achu
  • 9
  • 3
0
votes
2 answers

How to join two list into one on some common fields?

I want to join two list into one using deep copy. E.g. list1: [ {"key1":["val1"]}, {"key2":["val2", "val3"]} ] list2: [ {"key2":["val2", "val4"]}, {"key3":["val5"]} ] I want the output to be : [ {"key1":["val1"]}, …
Yuhui Liu
  • 97
  • 1
  • 6
0
votes
1 answer

Jsonnet object comprehension in array

I know how to do Array comprehension in Jsonnet like this, with the for loop the one object in the array gets looped with all my defined values: local values = [ 'foo', 'bar', 'foobar', ]; { list: 'movies', items: [ { title: 'title', …
0
votes
2 answers

How to replace part of string BEHIND search criteria in Jsonnet string?

I'm looking for an equivalent to std.strReplace(str, from, to) to replace parts of a string in Jsonnet. I would need from to be more like a "pattern", something like s/key="[^"]*"/key="myNewValue"/g, so actually what I'm looking for would be a…
Heiko Finzel
  • 78
  • 1
  • 8
0
votes
1 answer

Find and return element in (deep) object

I'll write "pseudo-python-jsonnet" code to show what I want to achieve. I really have no clue how to do something like that in jsonnet. local createCopy(gname, rname, kp) = for topLvlKey in…
Heiko Finzel
  • 78
  • 1
  • 8