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
GeneratorGidBuilder builder()Get builder for [json.generator.Generator] Returns: New builder objectuint 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 leveldchar getIndentChar()Retrieves the value set using [json.generator.Generator.setIndentChar]. Returns: the character to be used when indentingbool getPretty()Retrieves the value set using [json.generator.Generator.setPretty]. Returns: `TRUE` if the generated JSON should be pretty-printed, and `FALSE` otherwisejson.node.Node getRoot()Retrieves a pointer to the root node set using [json.generator.Generator.setRoot]. Returns: the root nodevoid 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.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 chainingT indentChar(uint propval)Set `indentChar` property. Params: propval = The character that should be used when indenting in pretty print. Returns: Builder instance for fluent chainingT 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