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 _gType() @property
Generator self()Returns `this`, for use in `with` statements.
GeneratorGidBuilder builder()Get builder for [json.generator.Generator] Returns: New builder object
uint indent() @propertyGet `indent` property. Returns: Number of spaces to be used to indent when pretty printing.
void indent(uint propval) @propertySet `indent` property. Params: propval = Number of spaces to be used to indent when pretty printing.
uint indentChar() @propertyGet `indentChar` property. Returns: The character that should be used when indenting in pretty print.
void indentChar(uint propval) @propertySet `indentChar` property. Params: propval = The character that should be used when indenting in pretty print.
bool pretty() @propertyGet `pretty` property. Returns: Whether the output should be "pretty-printed", with indentation and newlines.
void pretty(bool propval) @propertySet `pretty` property. Params: propval = Whether the output should be "pretty-printed", with indentation and newlines.
json.node.Node root() @propertyGet `root` property. Returns: The root node to be used when constructing a JSON data stream.
void root(json.node.Node propval) @propertySet `root` property. Params: propval = The root node to be used when constructing a JSON data stream.
uint getIndent()Retrieves the value set using [json.generator.Generator.setIndent]. Returns: the number of repetitions per indentation level
dchar getIndentChar()Retrieves the value set using [json.generator.Generator.setIndentChar]. Returns: the character to be used when indenting
bool getPretty()Retrieves 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()Retrieves a pointer to the root node set using [json.generator.Generator.setRoot]. Returns: the root node
void setIndent(uint indentLevel)Sets the number of repetitions for each indentation level.
void setIndentChar(dchar indentChar)Sets the character to be used when indenting.
void setPretty(bool isPretty)Sets whether the generated JSON should be pretty printed.
void setRoot(json.node.Node node)Sets the root of the JSON data stream to be serialized by the given generator.
string toData(out size_t length)Generates 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_)Generates 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].
Methods
T indent(uint propval)Set `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)Set `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)Set `pretty` property. Params: propval = Whether the output should be "pretty-printed", with indentation and newlines.
T root(json.node.Node propval)Set `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