Class to unparse json instances into JSON messages.
More...
#include <unparser.hpp>
|
| unparser (writer &w, const char *space=" ", const char *newline="", const char *indent=" ", int indent_inc=0) |
|
void | unparse (const json &j, int indent_level=0) |
|
|
static void | unparse (std::ostream &o, const json &j, const char *space=" ", const char *newline="", const char *indent=" ", int indent_inc=0) |
|
static void | unparse (int fd, const json &j, const char *space=" ", const char *newline="", const char *indent=" ", int indent_inc=0) |
|
static void | unparse (FILE *s, const json &j, const char *space=" ", const char *newline="", const char *indent=" ", int indent_inc=0) |
|
static void | save (const json &j, const std::string &file_name, const char *space=" ", const char *newline="", const char *indent=" ", int indent_inc=0) |
|
Class to unparse json instances into JSON messages.
Class to unparse json instances into JSON messages. Various convenience methods are supplied for different IO models.
Definition at line 54 of file unparser.hpp.
unparser::unparser |
( |
writer & |
w, |
|
|
const char * |
space = " " , |
|
|
const char * |
newline = "" , |
|
|
const char * |
indent = " " , |
|
|
int |
indent_inc = 0 |
|
) |
| |
Construct a new unparser given a writer instance.
- Parameters
-
w | The writer to use for output. |
space | What to print for the spacing around ":" and after ",". |
newline | What to print for a newline after name/value pairs and array items. |
indent | What to print for indents after a newline. |
indent_inc | How much to increment by when indenting a new object or array. 1 == one indent string parameter value. |
- Exceptions
-
Definition at line 44 of file unparser.cpp.
void unparser::save |
( |
const json & |
j, |
|
|
const std::string & |
file_name, |
|
|
const char * |
space = " " , |
|
|
const char * |
newline = "" , |
|
|
const char * |
indent = " " , |
|
|
int |
indent_inc = 0 |
|
) |
| |
|
static |
Convenience method. Create a new file, write a single JSON message to it and then close it. See documentation for unparse to stream for other parameter details.
- Exceptions
-
Definition at line 204 of file unparser.cpp.
void unparser::unparse |
( |
std::ostream & |
o, |
|
|
const json & |
j, |
|
|
const char * |
space = " " , |
|
|
const char * |
newline = "" , |
|
|
const char * |
indent = " " , |
|
|
int |
indent_inc = 0 |
|
) |
| |
|
static |
Unparse a json instance to an ostream.
- Parameters
-
o | The ostream to write to. |
j | The json instance to write. |
space | What to print for the spacing around ":" and after ",". |
newline | What to print for a newline after name/value pairs and array items. |
indent | What to print for indents after a newline. |
indent_inc | How much to increment by when indenting a new object or array. 1 == one indent string parameter value. |
- Exceptions
-
Definition at line 163 of file unparser.cpp.
void unparser::unparse |
( |
int |
fd, |
|
|
const json & |
j, |
|
|
const char * |
space = " " , |
|
|
const char * |
newline = "" , |
|
|
const char * |
indent = " " , |
|
|
int |
indent_inc = 0 |
|
) |
| |
|
static |
Unparse a json instance to a POSIX file descriptor. See documentation for unparse to stream for other parameter details.
- Exceptions
-
Definition at line 177 of file unparser.cpp.
void unparser::unparse |
( |
FILE * |
s, |
|
|
const json & |
j, |
|
|
const char * |
space = " " , |
|
|
const char * |
newline = "" , |
|
|
const char * |
indent = " " , |
|
|
int |
indent_inc = 0 |
|
) |
| |
|
static |
Unparse a json instance to a stdio FILE. See documentation for unparse to stream for other parameter details.
- Exceptions
-
Definition at line 191 of file unparser.cpp.
void unparser::unparse |
( |
const json & |
j, |
|
|
int |
indent_level = 0 |
|
) |
| |
Unparse a single json instance.
- Parameters
-
j | The json instance to output. |
indent_level | The indent level to start at (usually 0). |
- Exceptions
-
Definition at line 119 of file unparser.cpp.
The documentation for this class was generated from the following files: