3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>Function template write_json</title>
5 <link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
7 <link rel="home" href="../../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
8 <link rel="up" href="../../../property_tree/reference.html#header.boost.property_tree.json_parser_hpp" title="Header <boost/property_tree/json_parser.hpp>">
9 <link rel="prev" href="write_json_idp202532560.html" title="Function template write_json">
10 <link rel="next" href="../basic_ptree.html" title="Class template basic_ptree">
12 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13 <table cellpadding="2" width="100%"><tr>
14 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
15 <td align="center"><a href="../../../../../index.html">Home</a></td>
16 <td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
17 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19 <td align="center"><a href="../../../../../more/index.htm">More</a></td>
22 <div class="spirit-nav">
23 <a accesskey="p" href="write_json_idp202532560.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../property_tree/reference.html#header.boost.property_tree.json_parser_hpp"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../basic_ptree.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
25 <div class="refentry">
26 <a name="boost.property_tree.json_parser.write_json_idp210050192"></a><div class="titlepage"></div>
27 <div class="refnamediv">
28 <h2><span class="refentrytitle">Function template write_json</span></h2>
29 <p>boost::property_tree::json_parser::write_json</p>
31 <h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
32 <div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: <<a class="link" href="../../../property_tree/reference.html#header.boost.property_tree.json_parser_hpp" title="Header <boost/property_tree/json_parser.hpp>">boost/property_tree/json_parser.hpp</a>>
35 <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> Ptree<span class="special">></span>
36 <span class="keyword">void</span> <span class="identifier">write_json</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&</span> filename<span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Ptree</span> <span class="special">&</span> pt<span class="special">,</span>
37 <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">locale</span> <span class="special">&</span> loc <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">locale</span><span class="special">(</span><span class="special">)</span><span class="special">,</span>
38 <span class="keyword">bool</span> pretty <span class="special">=</span> <span class="keyword">true</span><span class="special">)</span><span class="special">;</span></pre></div>
39 <div class="refsect1">
40 <a name="idp349612352"></a><h2>Description</h2>
41 <p>Translates the property tree to JSON and writes it the given file. </p>
42 <div class="note"><table border="0" summary="Note">
44 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../doc/src/images/note.png"></td>
45 <th align="left">Note</th>
47 <tr><td align="left" valign="top"><p>Any property tree key containing only unnamed subkeys will be rendered as JSON arrays. </p></td></tr>
54 <div class="variablelist"><table border="0" class="variablelist compact">
56 <col align="left" valign="top">
61 <td><p><span class="term">Parameters:</span></p></td>
62 <td><div class="variablelist"><table border="0" class="variablelist compact">
64 <col align="left" valign="top">
69 <td><p><span class="term"><code class="computeroutput">filename</code></span></p></td>
70 <td><p>The name of the file to which to write the JSON representation of the property tree. </p></td>
73 <td><p><span class="term"><code class="computeroutput">loc</code></span></p></td>
74 <td><p>The locale to use when writing out to the output file. </p></td>
77 <td><p><span class="term"><code class="computeroutput">pretty</code></span></p></td>
78 <td><p>Whether to pretty-print. Defaults to true and last place for backward compatibility. </p></td>
81 <td><p><span class="term"><code class="computeroutput">pt</code></span></p></td>
82 <td><p>The property tree to translate to JSON and output. </p></td>
88 <td><p><span class="term">Requires:</span></p></td>
89 <td><p><span class="emphasis"><em>pt</em></span> cannot contain keys that have both subkeys and non-empty data. </p></td>
92 <td><p><span class="term">Throws:</span></p></td>
93 <td>json_parser_error In case of error translating the property tree to JSON or writing to the file. </td>
99 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
100 <td align="left"></td>
101 <td align="right"><div class="copyright-footer">Copyright © 2008 Marcin Kalicinski<p>
102 Distributed under the Boost Software License, Version 1.0. (See accompanying
103 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
108 <div class="spirit-nav">
109 <a accesskey="p" href="write_json_idp202532560.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../property_tree/reference.html#header.boost.property_tree.json_parser_hpp"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../basic_ptree.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>