Jsonnet

Latest version: v0.20.0

Safety actively analyzes 723144 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 6 of 7

0.8.2

This release:
- Adds unicode support (finally fixing 1)
- Extends the array and object comprehension syntax to arbtirary if / for specifiers
- Fixes a garbage collection bug when using assertions
- Adds std.count() std.startsWith() and std.endsWith()
- Re-organizes the source tree.

0.8.1

There are 2 major things in this release:

Asserts

The biggest change in this release is the addition of the assert construct. This is backwards-compatible except if you were using 'assert' as an identifier, in which case you'll have to rename it (or use quotes "assert": in the case of a field name).

Assert expressions


assert e1 : e2; e3


Is simply desugared to


if e1 then e3 else error e2


And the : e2 is optional like in Python and Java (except Python uses a comma instead of a colon).

Object assertions (invariants)

It is also possible to put asserts into objects:


local Base = {
assert self.x <= self.y : "%d greater than %d" % [self.x, self.y],
x: 1,
y: 2,
};


These are preserved over inheritance and follow the usual late binding semantics.


Base { x: 3 } // Raises an error.
Base { x: 3, y: 4 } // Ok.


This can be useful for enumerations:


local Base = {
assert std.setMember(self.animal, self.availableAnimals)
: "%s is not a valid animal" % self.animal,
animal: error "You must select an animal",
availableAnimals: ["CAT", "DOG"],
};
Base { animal: "FISH" } // Raises an error.
Base { animal: "FISH", availableAnimals+: ["FISH"] } // Ok.


If you want to constrain the base object so the animals cannot be extended, you can do:


local Base = {
local available_animals = ["CAT", "DOG"],
assert std.setMember(self.animal, available_animals)
: "%s is not a valid animal" % self.animal,
animal: error "You must select an animal",
};


Preventing override of fields

Finally, using this mechanism you can lock down a template so that users can only override the "inputs", not the "outputs". For example imagine building bash scripts as part of a workflow framework:


local Template = {
user:: error "Must set user",
command:: error "Must set command",
outputFile:: "out.log",

local template = self,
local output = {
bash: "sudo %(user)s \"%(command)s\" > %(outputFile)s" % template,
},
bash: output.bash,
assert self == output : "You may not override this template's output."
};
// User code:
Template {user: "myname", command: "ls", bash+:"; echo hi"}


This would produce an error because the assertion prevents the user from adding stuff onto the end of the bash command.

Removal of super as a construct in its own right

Early in development we decided to avoid restrictions in the language to see where this would lead us. Two such cases led to implementation complexity and we were tempted to remove them, but we were not sure if they would be useful. One case was mixins, which turned out to be enormously useful in many cases. The other case was the ability to do super by itself, not just in the context of super.f or super[e]. The semantics of this were tricky to define in the case of extending super, or extending super with itself (although we did so, and the rules are on the website)! It also makes the interpreter and object model harder to implement. To the best of our knowledge, there is not one single person using super in this fashion, so we have now restricted it to just super.f and super[e] as done in other languages.

0.8.0

This release has a few more examples.

The main new feature is the ability to specify multiline strings more easily, i.e. instead of the ugly


{
foo: "!/bin/bash
echo \"Hello world!\"",
}


or the bureaucratic


{
foo: std.lines([
"!/bin/bash"
"echo \"Hello world!\"",
])
}


you can now do the following, which is similar to the YAML "block style" construct.


{
foo: |||
!/bin/bash
echo "Hello world!"
|||,
}


The indentation is stripped.

Note that this is just a string literal, so it can be combined with % to do string templating:


{
foo: |||
!/bin/bash
echo "Hello %(greetable_entity)s!"
||| % {
greetable_entity: "world"
},
}

0.7.9

This release has the following changes since v0.7.6 (intermediate versions exist on PyPy but not Github):
- Add std.setMember
- Various bug fixes related to transitive imports not being correctly resolved
- Addition of import_callback to Python bindings

0.7.6

This release has the following changes:
- Various minor bug fixes.
- Replace garbage collector with one that can handle larger heaps.
- Add tailstrict function call annotation for O(1) memory consumption in tail-recursive functions.
- Added sort, uniq, and set functions to stdlib
- Python extension is now built with setup.py

0.7.5

Some minor fixes to the manifestation of large numbers, as well as new errors when computing NaN/Inf during execution.

Page 6 of 7

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.