scad 1.2.2

A crate for generating OpenSCAD models using rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="generator" content="rustdoc">
    <meta name="description" content="API documentation for the Rust `json` mod in crate `rustc_serialize`.">
    <meta name="keywords" content="rust, rustlang, rust-lang, json">

    <title>rustc_serialize::json - Rust</title>

    <link rel="stylesheet" type="text/css" href="../../rustdoc.css">
    <link rel="stylesheet" type="text/css" href="../../main.css">
    

    <link rel="shortcut icon" href="https://www.rust-lang.org/favicon.ico">
    
</head>
<body class="rustdoc">
    <!--[if lte IE 8]>
    <div class="warning">
        This old browser is unsupported and will most likely display funky
        things.
    </div>
    <![endif]-->

    

    <nav class="sidebar">
        <a href='../../rustc_serialize/index.html'><img src='https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png' alt='logo' width='100'></a>
        <p class='location'><a href='../index.html'>rustc_serialize</a></p><script>window.sidebarCurrent = {name: 'json', ty: 'mod', relpath: '../'};</script><script defer src="../sidebar-items.js"></script>
    </nav>

    <nav class="sub">
        <form class="search-form js-only">
            <div class="search-container">
                <input class="search-input" name="search"
                       autocomplete="off"
                       placeholder="Click or press ‘S’ to search, ‘?’ for more options…"
                       type="search">
            </div>
        </form>
    </nav>

    <section id='main' class="content mod">
<h1 class='fqn'><span class='in-band'>Module <a href='../index.html'>rustc_serialize</a>::<wbr><a class='mod' href=''>json</a></span><span class='out-of-band'><span id='render-detail'>
                   <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
                       [<span class='inner'>&#x2212;</span>]
                   </a>
               </span><a id='src-5134' class='srclink' href='../../src/rustc_serialize/json.rs.html#14-3955' title='goto source code'>[src]</a></span></h1>
<div class='docblock'><p>JSON parsing and serialization</p>

<h1 id='what-is-json' class='section-header'><a href='#what-is-json'>What is JSON?</a></h1>
<p>JSON (JavaScript Object Notation) is a way to write data in Javascript.
Like XML, it allows encoding structured data in a text format that can be
easily read by humans. Its simple syntax and native compatibility with
JavaScript have made it a widely used format.</p>

<p>Data types that can be encoded are JavaScript types (see the <code>Json</code> enum
for more details):</p>

<ul>
<li><code>I64</code>: equivalent to rust&#39;s <code>i64</code></li>
<li><code>U64</code>: equivalent to rust&#39;s <code>u64</code></li>
<li><code>F64</code>: equivalent to rust&#39;s <code>f64</code></li>
<li><code>Boolean</code>: equivalent to rust&#39;s <code>bool</code></li>
<li><code>String</code>: equivalent to rust&#39;s <code>String</code></li>
<li><code>Array</code>: equivalent to rust&#39;s <code>Vec&lt;T&gt;</code>, but also allowing objects of
different types in the
same array</li>
<li><code>Object</code>: equivalent to rust&#39;s <code>BTreeMap&lt;String, json::Json&gt;</code></li>
<li><code>Null</code></li>
</ul>

<p>An object is a series of string keys mapping to values, in <code>&quot;key&quot;: value</code>
format.  Arrays are enclosed in square brackets ([ ... ]) and objects in
curly brackets ({ ... }).  A simple JSON document encoding a person,
their age, address and phone numbers could look like</p>

<pre class='rust rust-example-rendered'>
{
    <span class='string'>&quot;FirstName&quot;</span>: <span class='string'>&quot;John&quot;</span>,
    <span class='string'>&quot;LastName&quot;</span>: <span class='string'>&quot;Doe&quot;</span>,
    <span class='string'>&quot;Age&quot;</span>: <span class='number'>43</span>,
    <span class='string'>&quot;Address&quot;</span>: {
        <span class='string'>&quot;Street&quot;</span>: <span class='string'>&quot;Downing Street 10&quot;</span>,
        <span class='string'>&quot;City&quot;</span>: <span class='string'>&quot;London&quot;</span>,
        <span class='string'>&quot;Country&quot;</span>: <span class='string'>&quot;Great Britain&quot;</span>
    },
    <span class='string'>&quot;PhoneNumbers&quot;</span>: [
        <span class='string'>&quot;+44 1234567&quot;</span>,
        <span class='string'>&quot;+44 2345678&quot;</span>
    ]
}<a class='test-arrow' target='_blank' href=''>Run</a></pre>

<h1 id='rust-type-based-encoding-and-decoding' class='section-header'><a href='#rust-type-based-encoding-and-decoding'>Rust Type-based Encoding and Decoding</a></h1>
<p>Rust provides a mechanism for low boilerplate encoding &amp; decoding of values
to and from JSON via the serialization API.  To be able to encode a piece
of data, it must implement the <code>rustc_serialize::Encodable</code> trait.  To be
able to decode a piece of data, it must implement the
<code>rustc_serialize::Decodable</code> trait.  The Rust compiler provides an
annotation to automatically generate the code for these traits:
<code>#[derive(RustcDecodable, RustcEncodable)]</code></p>

<p>The JSON API provides an enum <code>json::Json</code> and a trait <code>ToJson</code> to encode
objects.  The <code>ToJson</code> trait provides a <code>to_json</code> method to convert an
object into a <code>json::Json</code> value.  A <code>json::Json</code> value can be encoded as a
string or buffer using the functions described above.  You can also use the
<code>json::Encoder</code> object, which implements the <code>Encoder</code> trait.</p>

<p>When using <code>ToJson</code>, the <code>Encodable</code> trait implementation is not
mandatory.</p>

<h1 id='examples-of-use' class='section-header'><a href='#examples-of-use'>Examples of use</a></h1>
<h2 id='using-autoserialization' class='section-header'><a href='#using-autoserialization'>Using Autoserialization</a></h2>
<p>Create a struct called <code>TestStruct</code> and serialize and deserialize it to and
from JSON using the serialization API, using the derived serialization code.</p>

<pre class='rust rust-example-rendered'>
<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>rustc_serialize</span>;
<span class='kw'>use</span> <span class='ident'>rustc_serialize</span>::<span class='ident'>json</span>;

<span class='comment'>// Automatically generate `RustcDecodable` and `RustcEncodable` trait</span>
<span class='comment'>// implementations</span>
<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>RustcDecodable</span>, <span class='ident'>RustcEncodable</span>)]</span>
<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>TestStruct</span>  {
    <span class='ident'>data_int</span>: <span class='ident'>u8</span>,
    <span class='ident'>data_str</span>: <span class='ident'>String</span>,
    <span class='ident'>data_vector</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='ident'>u8</span><span class='op'>&gt;</span>,
}

<span class='kw'>fn</span> <span class='ident'>main</span>() {
    <span class='kw'>let</span> <span class='ident'>object</span> <span class='op'>=</span> <span class='ident'>TestStruct</span> {
        <span class='ident'>data_int</span>: <span class='number'>1</span>,
        <span class='ident'>data_str</span>: <span class='string'>&quot;homura&quot;</span>.<span class='ident'>to_string</span>(),
        <span class='ident'>data_vector</span>: <span class='macro'>vec</span><span class='macro'>!</span>[<span class='number'>2</span>,<span class='number'>3</span>,<span class='number'>4</span>,<span class='number'>5</span>],
    };

    <span class='comment'>// Serialize using `json::encode`</span>
    <span class='kw'>let</span> <span class='ident'>encoded</span> <span class='op'>=</span> <span class='ident'>json</span>::<span class='ident'>encode</span>(<span class='kw-2'>&amp;</span><span class='ident'>object</span>).<span class='ident'>unwrap</span>();

    <span class='comment'>// Deserialize using `json::decode`</span>
    <span class='kw'>let</span> <span class='ident'>decoded</span>: <span class='ident'>TestStruct</span> <span class='op'>=</span> <span class='ident'>json</span>::<span class='ident'>decode</span>(<span class='kw-2'>&amp;</span><span class='ident'>encoded</span>).<span class='ident'>unwrap</span>();
}<a class='test-arrow' target='_blank' href=''>Run</a></pre>

<h2 id='using-the-tojson-trait' class='section-header'><a href='#using-the-tojson-trait'>Using the <code>ToJson</code> trait</a></h2>
<p>The examples below use the <code>ToJson</code> trait to generate the JSON string,
which is required for custom mappings.</p>

<h3 id='simple-example-of-tojson-usage' class='section-header'><a href='#simple-example-of-tojson-usage'>Simple example of <code>ToJson</code> usage</a></h3>
<pre class='rust rust-example-rendered'>
<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>rustc_serialize</span>;
<span class='kw'>use</span> <span class='ident'>rustc_serialize</span>::<span class='ident'>json</span>::{<span class='self'>self</span>, <span class='ident'>ToJson</span>, <span class='ident'>Json</span>};

<span class='comment'>// A custom data structure</span>
<span class='kw'>struct</span> <span class='ident'>ComplexNum</span> {
    <span class='ident'>a</span>: <span class='ident'>f64</span>,
    <span class='ident'>b</span>: <span class='ident'>f64</span>,
}

<span class='comment'>// JSON value representation</span>
<span class='kw'>impl</span> <span class='ident'>ToJson</span> <span class='kw'>for</span> <span class='ident'>ComplexNum</span> {
    <span class='kw'>fn</span> <span class='ident'>to_json</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>) <span class='op'>-&gt;</span> <span class='ident'>Json</span> {
        <span class='ident'>Json</span>::<span class='ident'>String</span>(<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;{}+{}i&quot;</span>, <span class='self'>self</span>.<span class='ident'>a</span>, <span class='self'>self</span>.<span class='ident'>b</span>))
    }
}

<span class='comment'>// Only generate `RustcEncodable` trait implementation</span>
<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>RustcEncodable</span>)]</span>
<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>ComplexNumRecord</span> {
    <span class='ident'>uid</span>: <span class='ident'>u8</span>,
    <span class='ident'>dsc</span>: <span class='ident'>String</span>,
    <span class='ident'>val</span>: <span class='ident'>Json</span>,
}

<span class='kw'>fn</span> <span class='ident'>main</span>() {
    <span class='kw'>let</span> <span class='ident'>num</span> <span class='op'>=</span> <span class='ident'>ComplexNum</span> { <span class='ident'>a</span>: <span class='number'>0.0001</span>, <span class='ident'>b</span>: <span class='number'>12.539</span> };
    <span class='kw'>let</span> <span class='ident'>data</span>: <span class='ident'>String</span> <span class='op'>=</span> <span class='ident'>json</span>::<span class='ident'>encode</span>(<span class='kw-2'>&amp;</span><span class='ident'>ComplexNumRecord</span>{
        <span class='ident'>uid</span>: <span class='number'>1</span>,
        <span class='ident'>dsc</span>: <span class='string'>&quot;test&quot;</span>.<span class='ident'>to_string</span>(),
        <span class='ident'>val</span>: <span class='ident'>num</span>.<span class='ident'>to_json</span>(),
    }).<span class='ident'>unwrap</span>();
    <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;data: {}&quot;</span>, <span class='ident'>data</span>);
    <span class='comment'>// data: {&quot;uid&quot;:1,&quot;dsc&quot;:&quot;test&quot;,&quot;val&quot;:&quot;0.0001+12.539i&quot;};</span>
}<a class='test-arrow' target='_blank' href=''>Run</a></pre>

<h3 id='verbose-example-of-tojson-usage' class='section-header'><a href='#verbose-example-of-tojson-usage'>Verbose example of <code>ToJson</code> usage</a></h3>
<pre class='rust rust-example-rendered'>
<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>rustc_serialize</span>;
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>BTreeMap</span>;
<span class='kw'>use</span> <span class='ident'>rustc_serialize</span>::<span class='ident'>json</span>::{<span class='self'>self</span>, <span class='ident'>Json</span>, <span class='ident'>ToJson</span>};

<span class='comment'>// Only generate `Decodable` trait implementation</span>
<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>RustcDecodable</span>)]</span>
<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>TestStruct</span> {
    <span class='ident'>data_int</span>: <span class='ident'>u8</span>,
    <span class='ident'>data_str</span>: <span class='ident'>String</span>,
    <span class='ident'>data_vector</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='ident'>u8</span><span class='op'>&gt;</span>,
}

<span class='comment'>// Specify encoding method manually</span>
<span class='kw'>impl</span> <span class='ident'>ToJson</span> <span class='kw'>for</span> <span class='ident'>TestStruct</span> {
    <span class='kw'>fn</span> <span class='ident'>to_json</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>) <span class='op'>-&gt;</span> <span class='ident'>Json</span> {
        <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>d</span> <span class='op'>=</span> <span class='ident'>BTreeMap</span>::<span class='ident'>new</span>();
        <span class='comment'>// All standard types implement `to_json()`, so use it</span>
        <span class='ident'>d</span>.<span class='ident'>insert</span>(<span class='string'>&quot;data_int&quot;</span>.<span class='ident'>to_string</span>(), <span class='self'>self</span>.<span class='ident'>data_int</span>.<span class='ident'>to_json</span>());
        <span class='ident'>d</span>.<span class='ident'>insert</span>(<span class='string'>&quot;data_str&quot;</span>.<span class='ident'>to_string</span>(), <span class='self'>self</span>.<span class='ident'>data_str</span>.<span class='ident'>to_json</span>());
        <span class='ident'>d</span>.<span class='ident'>insert</span>(<span class='string'>&quot;data_vector&quot;</span>.<span class='ident'>to_string</span>(), <span class='self'>self</span>.<span class='ident'>data_vector</span>.<span class='ident'>to_json</span>());
        <span class='ident'>Json</span>::<span class='ident'>Object</span>(<span class='ident'>d</span>)
    }
}

<span class='kw'>fn</span> <span class='ident'>main</span>() {
    <span class='comment'>// Serialize using `ToJson`</span>
    <span class='kw'>let</span> <span class='ident'>input_data</span> <span class='op'>=</span> <span class='ident'>TestStruct</span> {
        <span class='ident'>data_int</span>: <span class='number'>1</span>,
        <span class='ident'>data_str</span>: <span class='string'>&quot;madoka&quot;</span>.<span class='ident'>to_string</span>(),
        <span class='ident'>data_vector</span>: <span class='macro'>vec</span><span class='macro'>!</span>[<span class='number'>2</span>,<span class='number'>3</span>,<span class='number'>4</span>,<span class='number'>5</span>],
    };
    <span class='kw'>let</span> <span class='ident'>json_obj</span>: <span class='ident'>Json</span> <span class='op'>=</span> <span class='ident'>input_data</span>.<span class='ident'>to_json</span>();
    <span class='kw'>let</span> <span class='ident'>json_str</span>: <span class='ident'>String</span> <span class='op'>=</span> <span class='ident'>json_obj</span>.<span class='ident'>to_string</span>();

    <span class='comment'>// Deserialize like before</span>
    <span class='kw'>let</span> <span class='ident'>decoded</span>: <span class='ident'>TestStruct</span> <span class='op'>=</span> <span class='ident'>json</span>::<span class='ident'>decode</span>(<span class='kw-2'>&amp;</span><span class='ident'>json_str</span>).<span class='ident'>unwrap</span>();
}<a class='test-arrow' target='_blank' href=''>Run</a></pre>

<h2 id='parsing-a-str-to-json-and-reading-the-result' class='section-header'><a href='#parsing-a-str-to-json-and-reading-the-result'>Parsing a <code>str</code> to <code>Json</code> and reading the result</a></h2>
<pre class='rust rust-example-rendered'>
<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>rustc_serialize</span>;
<span class='kw'>use</span> <span class='ident'>rustc_serialize</span>::<span class='ident'>json</span>::<span class='ident'>Json</span>;

<span class='kw'>fn</span> <span class='ident'>main</span>() {
    <span class='kw'>let</span> <span class='ident'>data</span> <span class='op'>=</span> <span class='ident'>Json</span>::<span class='ident'>from_str</span>(<span class='string'>&quot;{\&quot;foo\&quot;: 13, \&quot;bar\&quot;: \&quot;baz\&quot;}&quot;</span>).<span class='ident'>unwrap</span>();
    <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;data: {}&quot;</span>, <span class='ident'>data</span>);
    <span class='comment'>// data: {&quot;bar&quot;:&quot;baz&quot;,&quot;foo&quot;:13}</span>
    <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;object? {}&quot;</span>, <span class='ident'>data</span>.<span class='ident'>is_object</span>());
    <span class='comment'>// object? true</span>

    <span class='kw'>let</span> <span class='ident'>obj</span> <span class='op'>=</span> <span class='ident'>data</span>.<span class='ident'>as_object</span>().<span class='ident'>unwrap</span>();
    <span class='kw'>let</span> <span class='ident'>foo</span> <span class='op'>=</span> <span class='ident'>obj</span>.<span class='ident'>get</span>(<span class='string'>&quot;foo&quot;</span>).<span class='ident'>unwrap</span>();

    <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;array? {:?}&quot;</span>, <span class='ident'>foo</span>.<span class='ident'>as_array</span>());
    <span class='comment'>// array? None</span>
    <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;u64? {:?}&quot;</span>, <span class='ident'>foo</span>.<span class='ident'>as_u64</span>());
    <span class='comment'>// u64? Some(13u64)</span>

    <span class='kw'>for</span> (<span class='ident'>key</span>, <span class='ident'>value</span>) <span class='kw'>in</span> <span class='ident'>obj</span>.<span class='ident'>iter</span>() {
        <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;{}: {}&quot;</span>, <span class='ident'>key</span>, <span class='kw'>match</span> <span class='op'>*</span><span class='ident'>value</span> {
            <span class='ident'>Json</span>::<span class='ident'>U64</span>(<span class='ident'>v</span>) <span class='op'>=&gt;</span> <span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;{} (u64)&quot;</span>, <span class='ident'>v</span>),
            <span class='ident'>Json</span>::<span class='ident'>String</span>(<span class='kw-2'>ref</span> <span class='ident'>v</span>) <span class='op'>=&gt;</span> <span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;{} (string)&quot;</span>, <span class='ident'>v</span>),
            _ <span class='op'>=&gt;</span> <span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>&quot;other&quot;</span>)
        });
    }
    <span class='comment'>// bar: baz (string)</span>
    <span class='comment'>// foo: 13 (u64)</span>
}<a class='test-arrow' target='_blank' href=''>Run</a></pre>

<h1 id='the-status-of-this-library' class='section-header'><a href='#the-status-of-this-library'>The status of this library</a></h1>
<p>While this library is the standard way of working with JSON in Rust,
there is a next-generation library called Serde that&#39;s in the works (it&#39;s
faster, overcomes some design limitations of rustc-serialize and has more
features). You might consider using it when starting a new project or
evaluating Rust JSON performance.</p>
</div><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
<table>
                       <tr class=' module-item'>
                           <td><a class='struct' href='struct.AsJson.html'
                                  title='rustc_serialize::json::AsJson'>AsJson</a></td>
                           <td class='docblock-short'>
                                
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='struct' href='struct.AsPrettyJson.html'
                                  title='rustc_serialize::json::AsPrettyJson'>AsPrettyJson</a></td>
                           <td class='docblock-short'>
                                
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='struct' href='struct.Builder.html'
                                  title='rustc_serialize::json::Builder'>Builder</a></td>
                           <td class='docblock-short'>
                                <p>A Builder consumes a json::Parser to create a generic Json structure.</p>
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='struct' href='struct.Decoder.html'
                                  title='rustc_serialize::json::Decoder'>Decoder</a></td>
                           <td class='docblock-short'>
                                <p>A structure to decode JSON to values in rust.</p>
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='struct' href='struct.Encoder.html'
                                  title='rustc_serialize::json::Encoder'>Encoder</a></td>
                           <td class='docblock-short'>
                                <p>A structure for implementing serialization to JSON.</p>
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='struct' href='struct.Parser.html'
                                  title='rustc_serialize::json::Parser'>Parser</a></td>
                           <td class='docblock-short'>
                                <p>A streaming JSON parser implemented as an iterator of JsonEvent, consuming
an iterator of char.</p>
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='struct' href='struct.PrettyJson.html'
                                  title='rustc_serialize::json::PrettyJson'>PrettyJson</a></td>
                           <td class='docblock-short'>
                                
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='struct' href='struct.Stack.html'
                                  title='rustc_serialize::json::Stack'>Stack</a></td>
                           <td class='docblock-short'>
                                <p>A Stack represents the current position of the parser in the logical
structure of the JSON stream.
For example foo.bar[3].x</p>
                           </td>
                       </tr></table><h2 id='enums' class='section-header'><a href="#enums">Enums</a></h2>
<table>
                       <tr class=' module-item'>
                           <td><a class='enum' href='enum.DecoderError.html'
                                  title='rustc_serialize::json::DecoderError'>DecoderError</a></td>
                           <td class='docblock-short'>
                                
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='enum' href='enum.EncoderError.html'
                                  title='rustc_serialize::json::EncoderError'>EncoderError</a></td>
                           <td class='docblock-short'>
                                
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='enum' href='enum.ErrorCode.html'
                                  title='rustc_serialize::json::ErrorCode'>ErrorCode</a></td>
                           <td class='docblock-short'>
                                <p>The errors that can arise while parsing a JSON stream.</p>
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='enum' href='enum.Json.html'
                                  title='rustc_serialize::json::Json'>Json</a></td>
                           <td class='docblock-short'>
                                <p>Represents a json value</p>
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='enum' href='enum.JsonEvent.html'
                                  title='rustc_serialize::json::JsonEvent'>JsonEvent</a></td>
                           <td class='docblock-short'>
                                <p>The output of the streaming parser.</p>
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='enum' href='enum.ParserError.html'
                                  title='rustc_serialize::json::ParserError'>ParserError</a></td>
                           <td class='docblock-short'>
                                
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='enum' href='enum.StackElement.html'
                                  title='rustc_serialize::json::StackElement'>StackElement</a></td>
                           <td class='docblock-short'>
                                <p>StackElements compose a Stack.
For example, Key(&quot;foo&quot;), Key(&quot;bar&quot;), Index(3) and Key(&quot;x&quot;) are the
StackElements compositing the stack that represents foo.bar[3].x</p>
                           </td>
                       </tr></table><h2 id='traits' class='section-header'><a href="#traits">Traits</a></h2>
<table>
                       <tr class=' module-item'>
                           <td><a class='trait' href='trait.ToJson.html'
                                  title='rustc_serialize::json::ToJson'>ToJson</a></td>
                           <td class='docblock-short'>
                                <p>A trait for converting values to JSON</p>
                           </td>
                       </tr></table><h2 id='functions' class='section-header'><a href="#functions">Functions</a></h2>
<table>
                       <tr class=' module-item'>
                           <td><a class='fn' href='fn.as_json.html'
                                  title='rustc_serialize::json::as_json'>as_json</a></td>
                           <td class='docblock-short'>
                                <p>Create an <code>AsJson</code> wrapper which can be used to print a value as JSON
on-the-fly via <code>write!</code></p>
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='fn' href='fn.as_pretty_json.html'
                                  title='rustc_serialize::json::as_pretty_json'>as_pretty_json</a></td>
                           <td class='docblock-short'>
                                <p>Create an <code>AsPrettyJson</code> wrapper which can be used to print a value as JSON
on-the-fly via <code>write!</code></p>
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='fn' href='fn.decode.html'
                                  title='rustc_serialize::json::decode'>decode</a></td>
                           <td class='docblock-short'>
                                <p>Shortcut function to decode a JSON <code>&amp;str</code> into an object</p>
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='fn' href='fn.encode.html'
                                  title='rustc_serialize::json::encode'>encode</a></td>
                           <td class='docblock-short'>
                                <p>Shortcut function to encode a <code>T</code> into a JSON <code>String</code></p>
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='fn' href='fn.error_str.html'
                                  title='rustc_serialize::json::error_str'>error_str</a></td>
                           <td class='docblock-short'>
                                <p>Returns a readable error string for a given error code.</p>
                           </td>
                       </tr></table><h2 id='types' class='section-header'><a href="#types">Type Definitions</a></h2>
<table>
                       <tr class=' module-item'>
                           <td><a class='type' href='type.Array.html'
                                  title='rustc_serialize::json::Array'>Array</a></td>
                           <td class='docblock-short'>
                                
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='type' href='type.BuilderError.html'
                                  title='rustc_serialize::json::BuilderError'>BuilderError</a></td>
                           <td class='docblock-short'>
                                
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='type' href='type.DecodeResult.html'
                                  title='rustc_serialize::json::DecodeResult'>DecodeResult</a></td>
                           <td class='docblock-short'>
                                
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='type' href='type.EncodeResult.html'
                                  title='rustc_serialize::json::EncodeResult'>EncodeResult</a></td>
                           <td class='docblock-short'>
                                
                           </td>
                       </tr>
                       <tr class=' module-item'>
                           <td><a class='type' href='type.Object.html'
                                  title='rustc_serialize::json::Object'>Object</a></td>
                           <td class='docblock-short'>
                                
                           </td>
                       </tr></table></section>
    <section id='search' class="content hidden"></section>

    <section class="footer"></section>

    <aside id="help" class="hidden">
        <div>
            <h1 class="hidden">Help</h1>

            <div class="shortcuts">
                <h2>Keyboard Shortcuts</h2>

                <dl>
                    <dt>?</dt>
                    <dd>Show this help dialog</dd>
                    <dt>S</dt>
                    <dd>Focus the search field</dd>
                    <dt>&larrb;</dt>
                    <dd>Move up in search results</dd>
                    <dt>&rarrb;</dt>
                    <dd>Move down in search results</dd>
                    <dt>&#9166;</dt>
                    <dd>Go to active search result</dd>
                    <dt>+</dt>
                    <dd>Collapse/expand all sections</dd>
                </dl>
            </div>

            <div class="infos">
                <h2>Search Tricks</h2>

                <p>
                    Prefix searches with a type followed by a colon (e.g.
                    <code>fn:</code>) to restrict the search to a given type.
                </p>

                <p>
                    Accepted types are: <code>fn</code>, <code>mod</code>,
                    <code>struct</code>, <code>enum</code>,
                    <code>trait</code>, <code>type</code>, <code>macro</code>,
                    and <code>const</code>.
                </p>

                <p>
                    Search functions by type signature (e.g.
                    <code>vec -> usize</code> or <code>* -> vec</code>)
                </p>
            </div>
        </div>
    </aside>

    

    <script>
        window.rootPath = "../../";
        window.currentCrate = "rustc_serialize";
        window.playgroundUrl = "";
    </script>
    <script src="../../jquery.js"></script>
    <script src="../../main.js"></script>
    
    <script defer src="../../search-index.js"></script>
</body>
</html>