| 1 |
--- |
| 2 |
layout: default |
| 3 |
title: Jsonnet Configuration Language |
| 4 |
--- |
| 5 |
|
| 6 |
<div class=hgroup> |
| 7 |
<div class=hgroup-inline> |
| 8 |
<div class=panel> |
| 9 |
<table> |
| 10 |
<tr> |
| 11 |
<td><img id=big-logo src=img/isologo.svg></td> |
| 12 |
<td class=side-text> |
| 13 |
<p> |
| 14 |
A configuration language<br> |
| 15 |
for app and tool developers |
| 16 |
</p> |
| 17 |
<ul> |
| 18 |
<li>Generate config data</li> |
| 19 |
<li>Side-effect free</li> |
| 20 |
<li>Organize, simplify, unify</li> |
| 21 |
<li>Manage sprawling config</li> |
| 22 |
</ul> |
| 23 |
</td> |
| 24 |
</tr> |
| 25 |
</table> |
| 26 |
</div> |
| 27 |
<div class=panel> |
| 28 |
<table class=venn> |
| 29 |
<tr> |
| 30 |
<td> |
| 31 |
<p> |
| 32 |
A simple extension of <a href="https://json.org/">JSON</a><br> |
| 33 |
</p> |
| 34 |
<ul> |
| 35 |
<li>Open source (Apache 2.0)</li> |
| 36 |
<li>Familiar syntax</li> |
| 37 |
<li>Reformatter, linter</li> |
| 38 |
<li>Editor & IDE integrations</li> |
| 39 |
<li>Formally specified</li> |
| 40 |
</ul> |
| 41 |
</td> |
| 42 |
<td class=venn-cell><img id=venn src=img/venn.svg></td> |
| 43 |
</tr> |
| 44 |
</table> |
| 45 |
</div> |
| 46 |
<div style="clear: both"></div> |
| 47 |
</div> |
| 48 |
</div> |
| 49 |
|
| 50 |
<div class=hgroup> |
| 51 |
<div class=hgroup-inline> |
| 52 |
<div class=panel> |
| 53 |
<p class=center>Eliminate duplication with object-orientation:</p> |
| 54 |
</div> |
| 55 |
<div style="clear: both"></div> |
| 56 |
</div> |
| 57 |
</div> |
| 58 |
|
| 59 |
<div class="inverse hgroup"> |
| 60 |
<div class=hgroup-inline> |
| 61 |
<div class="tab-window-input" id="example1-input"> |
| 62 |
<div class="tab-header"> |
| 63 |
</div> |
| 64 |
<textarea id=example1-jsonnet autofocus> |
| 65 |
// Edit me! |
| 66 |
{ |
| 67 |
person1: { |
| 68 |
name: "Alice", |
| 69 |
welcome: "Hello " + self.name + "!", |
| 70 |
}, |
| 71 |
person2: self.person1 { name: "Bob" }, |
| 72 |
} |
| 73 |
</textarea> |
| 74 |
</div> |
| 75 |
<div class="bigarrow">➡</div> |
| 76 |
<div class="tab-window-output" id="example1-output"> |
| 77 |
<div class="tab-header"> |
| 78 |
<div class=selected onclick="tab_output_click(this, 'example1-json-output')"> |
| 79 |
output.json |
| 80 |
</div> |
| 81 |
</div> |
| 82 |
<textarea readonly class="selected code-json" id="example1-json-output"> |
| 83 |
{ |
| 84 |
"person1": { |
| 85 |
"name": "Alice", |
| 86 |
"welcome": "Hello Alice!" |
| 87 |
}, |
| 88 |
"person2": { |
| 89 |
"name": "Bob", |
| 90 |
"welcome": "Hello Bob!" |
| 91 |
} |
| 92 |
} |
| 93 |
</textarea> |
| 94 |
</div> |
| 95 |
<script> |
| 96 |
demo( |
| 97 |
'example1-input', |
| 98 |
{ |
| 99 |
'example1-jsonnet': 'example1.jsonnet', |
| 100 |
}, |
| 101 |
'example1.jsonnet', |
| 102 |
'example1-output', |
| 103 |
false, |
| 104 |
false |
| 105 |
); |
| 106 |
</script> |
| 107 |
<div style="clear: both"></div> |
| 108 |
</div> |
| 109 |
</div> |
| 110 |
|
| 111 |
<div class=hgroup> |
| 112 |
<div class=hgroup-inline> |
| 113 |
<div class=panel> |
| 114 |
<p class=center>Or, use functions:</p> |
| 115 |
</div> |
| 116 |
<div style="clear: both"></div> |
| 117 |
</div> |
| 118 |
</div> |
| 119 |
|
| 120 |
<div class="inverse hgroup"> |
| 121 |
<div class=hgroup-inline> |
| 122 |
<div class="tab-window-input" id="example2-input"> |
| 123 |
<div class="tab-header"> |
| 124 |
</div> |
| 125 |
<textarea id=example2-jsonnet autofocus> |
| 126 |
// A function that returns an object. |
| 127 |
local Person(name='Alice') = { |
| 128 |
name: name, |
| 129 |
welcome: 'Hello ' + name + '!', |
| 130 |
}; |
| 131 |
{ |
| 132 |
person1: Person(), |
| 133 |
person2: Person('Bob'), |
| 134 |
} |
| 135 |
</textarea> |
| 136 |
</div> |
| 137 |
<div class="bigarrow">➡</div> |
| 138 |
<div class="tab-window-output" id="example2-output"> |
| 139 |
<div class="tab-header"> |
| 140 |
<div class=selected onclick="tab_output_click(this, 'example2-json-output')"> |
| 141 |
output.json |
| 142 |
</div> |
| 143 |
</div> |
| 144 |
<textarea readonly class="selected code-json" id="example2-json-output"> |
| 145 |
{ |
| 146 |
"person1": { |
| 147 |
"name": "Alice", |
| 148 |
"welcome": "Hello Alice!" |
| 149 |
}, |
| 150 |
"person2": { |
| 151 |
"name": "Bob", |
| 152 |
"welcome": "Hello Bob!" |
| 153 |
} |
| 154 |
} |
| 155 |
</textarea> |
| 156 |
</div> |
| 157 |
<script> |
| 158 |
demo( |
| 159 |
'example2-input', |
| 160 |
{ |
| 161 |
'example2-jsonnet': 'example2.jsonnet', |
| 162 |
}, |
| 163 |
'example2.jsonnet', |
| 164 |
'example2-output', |
| 165 |
false, |
| 166 |
false |
| 167 |
); |
| 168 |
</script> |
| 169 |
<div style="clear: both"></div> |
| 170 |
</div> |
| 171 |
</div> |
| 172 |
|
| 173 |
<div class=hgroup> |
| 174 |
<div class=hgroup-inline> |
| 175 |
<div class=panel> |
| 176 |
<p class=center> |
| 177 |
Integrate with existing / custom applications.<br> |
| 178 |
Generate JSON, YAML, INI, and other formats. |
| 179 |
</p> |
| 180 |
</div> |
| 181 |
<div style="clear: both"></div> |
| 182 |
</div> |
| 183 |
</div> |
| 184 |
|
| 185 |
<div class="inverse hgroup"> |
| 186 |
<div class=hgroup-inline> |
| 187 |
<div class="tab-window-input" id="example3-input"> |
| 188 |
<div class="tab-header"> |
| 189 |
</div> |
| 190 |
<textarea id=example3-jsonnet> |
| 191 |
local application = 'my-app'; |
| 192 |
local module = 'uwsgi_module'; |
| 193 |
local dir = '/var/www'; |
| 194 |
local permission = 644; |
| 195 |
|
| 196 |
{ |
| 197 |
'uwsgi.ini': std.manifestIni({ |
| 198 |
sections: { |
| 199 |
uwsgi: { |
| 200 |
module: module, |
| 201 |
pythonpath: dir, |
| 202 |
socket: dir + '/uwsgi.sock', |
| 203 |
'chmod-socket': permission, |
| 204 |
callable: application, |
| 205 |
logto: '/var/log/uwsgi/uwsgi.log', |
| 206 |
}, |
| 207 |
}, |
| 208 |
}), |
| 209 |
|
| 210 |
'init.sh': ||| |
| 211 |
#!/usr/bin/env bash |
| 212 |
mkdir -p %(dir)s |
| 213 |
touch %(dir)s/initialized |
| 214 |
chmod %(perm)d %(dir)s/initialized |
| 215 |
||| % {dir: dir, perm: permission}, |
| 216 |
|
| 217 |
'cassandra.conf': std.manifestYamlDoc({ |
| 218 |
cluster_name: application, |
| 219 |
seed_provider: [ |
| 220 |
{ |
| 221 |
class_name: 'SimpleSeedProvider', |
| 222 |
parameters: [{ seeds: '127.0.0.1' }], |
| 223 |
}, |
| 224 |
], |
| 225 |
}), |
| 226 |
} |
| 227 |
</textarea> |
| 228 |
</div> |
| 229 |
<div class="bigarrow">➡</div> |
| 230 |
<div class="tab-window-output" id="example3-output"> |
| 231 |
<div class="tab-header"> |
| 232 |
<div class=selected onclick="tab_output_click(this, 'example3-yaml-output')"> |
| 233 |
cassandra.conf |
| 234 |
</div> |
| 235 |
<div class=unselected onclick="tab_output_click(this, 'example3-sh-output')"> |
| 236 |
init.sh |
| 237 |
</div> |
| 238 |
<div class=unselected onclick="tab_output_click(this, 'example3-ini-output')"> |
| 239 |
uwsgi.ini |
| 240 |
</div> |
| 241 |
</div> |
| 242 |
<textarea readonly class="selected code-json" id="example3-yaml-output"> |
| 243 |
"cluster_name": "my-app" |
| 244 |
"seed_provider": |
| 245 |
- "class_name": "SimpleSeedProvider" |
| 246 |
"parameters": |
| 247 |
- "seeds": "127.0.0.1" |
| 248 |
</textarea> |
| 249 |
<textarea readonly class="unselected code-json" id="example3-sh-output"> |
| 250 |
#!/usr/bin/env bash |
| 251 |
mkdir -p /var/www |
| 252 |
touch /var/www/initialized |
| 253 |
chmod 644 /var/www/initialized |
| 254 |
</textarea> |
| 255 |
<textarea readonly class="unselected code-json" id="example3-ini-output"> |
| 256 |
[uwsgi] |
| 257 |
callable = my-app |
| 258 |
chmod-socket = 644 |
| 259 |
logto = /var/log/uwsgi/uwsgi.log |
| 260 |
module = uwsgi_module |
| 261 |
pythonpath = /var/www |
| 262 |
socket = /var/www/uwsgi.sock |
| 263 |
</textarea> |
| 264 |
</div> |
| 265 |
<script> |
| 266 |
demo( |
| 267 |
'example3-input', |
| 268 |
{ |
| 269 |
'example3-jsonnet': 'example3.jsonnet', |
| 270 |
}, |
| 271 |
'example3.jsonnet', |
| 272 |
'example3-output', |
| 273 |
true, |
| 274 |
true |
| 275 |
); |
| 276 |
</script> |
| 277 |
<div style="clear: both"></div> |
| 278 |
</div> |
| 279 |
</div> |
| 280 |
|
| 281 |
<div class=hgroup> |
| 282 |
<div class=hgroup-inline> |
| 283 |
<div class=panel> |
| 284 |
<p class=padded> |
| 285 |
The name Jsonnet is a portmanteau of JSON and <a |
| 286 |
href="https://en.wikipedia.org/wiki/Sonnet"><i>sonnet</i></a>, pronounced "jay sonnet". It |
| 287 |
began life early 2014 as a 20% project and was launched on Aug 6. The design is influenced |
| 288 |
by several configuration languages internal to Google, and embodies years of experience |
| 289 |
configuring some of the world's most complex IT systems. Jsonnet is now used by many |
| 290 |
companies and projects. Jsonnet is not an official Google product (experimental or |
| 291 |
otherwise), it is just code that happens to be owned by Google. |
| 292 |
</p> |
| 293 |
</div> |
| 294 |
|
| 295 |
<div class=panel> |
| 296 |
<p class=center> |
| 297 |
<a href='https://bitnami.com'><img class=user-logo src=img/users/bitnami.png></a> |
| 298 |
<!-- |
| 299 |
<a href='https://www.box.com'><img class=user-logo src=img/users/box.jpg></a> |
| 300 |
<a href='https://coreos.com'><img class=user-logo src=img/users/coreos.svg></a> |
| 301 |
<a href='https://databricks.com'><img class=user-logo src=img/users/databricks.png></a> |
| 302 |
<a href='https://vr.google.com/daydream/'> |
| 303 |
<img class=user-logo src=img/users/daydream-logo.png></a> |
| 304 |
--> |
| 305 |
<a href='https://deepmind.com'><img class=user-logo src=img/users/deepmind.png></a> |
| 306 |
<a href='https://grafana.com'><img class=user-logo src=img/users/grafana.svg></a> |
| 307 |
<!-- |
| 308 |
<a href='https://www.spinnaker.io'><img class=user-logo src=img/users/spinnaker.png></a> |
| 309 |
--> |
| 310 |
</p class=center> |
| 311 |
</div> |
| 312 |
<div style="clear: both"></div> |
| 313 |
</div> |
| 314 |
</div> |