Skip to content

Instantly share code, notes, and snippets.

@jjo
Created October 31, 2021 12:53
Show Gist options
  • Save jjo/58163b71b24991b1b3c9bad7516f35e8 to your computer and use it in GitHub Desktop.
Save jjo/58163b71b24991b1b3c9bad7516f35e8 to your computer and use it in GitHub Desktop.
$ /tmp cat > foo.jsonnet
local applyModifications(obj, f) =
obj + {
[x] : f(obj[x]) for x in std.objectFieldsAll(obj)
}
;
applyModifications({
visible: "foo",
hidden:: "bar",
}, function(x) x + " modified")
$ /tmp jsonnet foo.jsonnet
{
"hidden": "bar modified",
"visible": "foo modified"
}
$ /tmp jsonnet --version
Jsonnet commandline interpreter v0.17.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment