Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.
PrevUpHomeNext

Function template write_json

boost::property_tree::json_parser::write_json

Synopsis

// In header: <boost/property_tree/json_parser.hpp>


template<typename Ptree> 
  void write_json(const std::string & filename, const Ptree & pt, 
                  const std::locale & loc = std::locale(), 
                  bool pretty = true);

Description

Translates the property tree to JSON and writes it the given file.

[Note] Note

Any property tree key containing only unnamed subkeys will be rendered as JSON arrays.

Parameters:

filename

The name of the file to which to write the JSON representation of the property tree.

loc

The locale to use when writing out to the output file.

pretty

Whether to pretty-print. Defaults to true and last place for backward compatibility.

pt

The property tree to translate to JSON and output.

Requires:

pt cannot contain keys that have both subkeys and non-empty data.

Throws:

json_parser_error In case of error translating the property tree to JSON or writing to the file.

PrevUpHomeNext