json.generator

Module for [Generator] class

Types 3

json.generator.Generator provides an object for generating a JSON data stream from a tree of json.node.Node instances, and put it into a buffer or a file.

Methods
GType _getGType() static nothrow
GType _gType() @property nothrow
Generator self() nothrowReturns `this`, for use in `with` statements.
GeneratorGidBuilder builder() static nothrowGet builder for [json.generator.Generator] Returns: New builder object
uint indent() @property nothrowGet `indent` property. Returns: Number of spaces to be used to indent when pretty printing.
void indent(uint propval) @property nothrowSet `indent` property. Params: propval = Number of spaces to be used to indent when pretty printing.
uint indentChar() @property nothrowGet `indentChar` property. Returns: The character that should be used when indenting in pretty print.
void indentChar(uint propval) @property nothrowSet `indentChar` property. Params: propval = The character that should be used when indenting in pretty print.
bool pretty() @property nothrowGet `pretty` property. Returns: Whether the output should be "pretty-printed", with indentation and newlines.
void pretty(bool propval) @property nothrowSet `pretty` property. Params: propval = Whether the output should be "pretty-printed", with indentation and newlines.
json.node.Node root() @property nothrowGet `root` property. Returns: The root node to be used when constructing a JSON data stream.
void root(json.node.Node propval) @property nothrowSet `root` property. Params: propval = The root node to be used when constructing a JSON data stream.
uint getIndent() nothrowRetrieves the value set using [json.generator.Generator.setIndent]. Returns: the number of repetitions per indentation level
dchar getIndentChar() nothrowRetrieves the value set using [json.generator.Generator.setIndentChar]. Returns: the character to be used when indenting
bool getPretty() nothrowRetrieves the value set using [json.generator.Generator.setPretty]. Returns: `TRUE` if the generated JSON should be pretty-printed, and `FALSE` otherwise
json.node.Node getRoot() nothrowRetrieves a pointer to the root node set using [json.generator.Generator.setRoot]. Returns: the root node
void setIndent(uint indentLevel) nothrowSets the number of repetitions for each indentation level.
void setIndentChar(dchar indentChar) nothrowSets the character to be used when indenting.
void setPretty(bool isPretty) nothrowSets whether the generated JSON should be pretty printed.
void setRoot(json.node.Node node) nothrowSets the root of the JSON data stream to be serialized by the given generator.
string toData(out size_t length) nothrowGenerates a JSON data stream from generator and returns it as a buffer.
bool toFile(string filename)Creates a JSON data stream and puts it inside `filename`, overwriting the file's current contents.
glib.string_.String toGstring(glib.string_.String string_) nothrowGenerates a JSON data stream and appends it to the string buffer.
bool toStream(gio.output_stream.OutputStream stream, gio.cancellable.Cancellable cancellable = null)Outputs JSON data and writes it (synchronously) to the given stream.
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a new [json.generator.Generator].

Fluent builder implementation template for json.generator.Generator

Methods
T indent(uint propval) nothrowSet `indent` property. Params: propval = Number of spaces to be used to indent when pretty printing. Returns: Builder instance for fluent chaining
T indentChar(uint propval) nothrowSet `indentChar` property. Params: propval = The character that should be used when indenting in pretty print. Returns: Builder instance for fluent chaining
T pretty(bool propval) nothrowSet `pretty` property. Params: propval = Whether the output should be "pretty-printed", with indentation and newlines.
T root(json.node.Node propval) nothrowSet `root` property. Params: propval = The root node to be used when constructing a JSON data stream. Returns: Builder instance for fluent chaining

Fluent builder for json.generator.Generator

Methods
Generator build() nothrowCreate object from builder. Returns: New object