Skip to content

Commit ace4d74

Browse files
doc: document the --string / -S option in getting_started
Fixes #852
1 parent 3188865 commit ace4d74

File tree

1 file changed

+53
-3
lines changed

1 file changed

+53
-3
lines changed

doc/learning/getting_started.html

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,57 @@ <h3 id="example">Example</h3>
103103
</div>
104104

105105

106+
<div class="hgroup">
107+
<div class="hgroup-inline">
108+
<div class="panel">
109+
<h3 id="text_output">Generating non-JSON output</h3>
110+
</div>
111+
<div style="clear: both"></div>
112+
</div>
113+
</div>
114+
115+
116+
<div class="hgroup">
117+
<div class="hgroup-inline">
118+
<div class="panel">
119+
<p>
120+
Sometimes it is useful to generate output that is not in JSON format. You can do this by
121+
writing Jsonnet code which evaluates to a string containing whatever your desired format
122+
is. When executed with <tt>jsonnet -S</tt> or <tt>jsonnet --string</tt> jsonnet will
123+
manifest the string result as plain text rather than a JSON-formatted string.
124+
</p>
125+
126+
<pre>// ini_output.jsonnet
127+
std.manifestIni({
128+
sections: {
129+
main: {
130+
host: "127.0.0.1",
131+
port: "9000",
132+
},
133+
database: {
134+
path: "/var/data",
135+
},
136+
},
137+
})</pre>
138+
139+
<p>
140+
When executed using <tt>jsonnet -S ini_output.jsonnet</tt>, this will output the generated
141+
INI formatted text directly.
142+
</p>
143+
144+
<pre>$ jsonnet -S ini_output.jsonnet
145+
[database]
146+
path = /var/data
147+
[main]
148+
host = 127.0.0.1
149+
port = 9000</pre>
150+
151+
</div>
152+
<div style="clear: both"></div>
153+
</div>
154+
</div>
155+
156+
106157
<div class="hgroup">
107158
<div class="hgroup-inline">
108159
<div class="panel">
@@ -148,12 +199,12 @@ <h3 id="multi">Multiple File Output</h3>
148199
<pre>$ jsonnet -m . multiple_output.jsonnet
149200
a.json
150201
b.json
151-
$ cat a.json
202+
$ cat a.json
152203
{
153204
"x": 1,
154205
"y": 2
155206
}
156-
$ cat b.json
207+
$ cat b.json
157208
{
158209
"x": 1,
159210
"y": 2
@@ -288,4 +339,3 @@ <h2 id="javascript">JavaScript</h2>
288339
<div style="clear: both"></div>
289340
</div>
290341
</div>
291-

0 commit comments

Comments
 (0)