Generator
Object Hierarchy:
Description:
[
CCode ( type_id =
"json_generator_get_type ()" ) ]
public class Generator :
Object
`JsonGenerator` provides an object for generating a JSON data stream from a tree of [struct@Json.
Node] instances, and put it into a buffer or a file.
Content:
Properties:
- public uint indent { get; set; }
Number of spaces to be used to indent when pretty printing.
- public uint indent_char { get; set; }
The character that should be used when indenting in pretty print.
- public bool pretty { get; set; }
Whether the output should be "pretty-printed", with indentation and
newlines.
- public Node root { get; set; }
The root node to be used when constructing a JSON data stream.
Creation methods:
Methods:
- public uint get_indent ()
Retrieves the value set using [method@Json.
- public unichar get_indent_char ()
Retrieves the value set using [method@Json.
- public bool get_pretty ()
Retrieves the value set using [method@Json.
- public unowned Node? get_root ()
Retrieves a pointer to the root node set using [method@Json.
- public void set_indent (uint indent_level)
Sets the number of repetitions for each indentation level.
- public void set_indent_char (unichar indent_char)
Sets the character to be used when indenting.
- public void set_pretty (bool is_pretty)
Sets whether the generated JSON should be pretty printed.
- public void set_root (Node node)
Sets the root of the JSON data stream to be serialized by the given
generator.
- public string to_data (out size_t length)
Generates a JSON data stream from this
and returns it as a buffer.
- public bool to_file (string filename) throws Error
Creates a JSON data stream and puts it inside `filename`, overwriting
the file's current contents.
- public unowned StringBuilder to_gstring (StringBuilder string)
Generates a JSON data stream and appends it to the string buffer.
- public bool to_stream (OutputStream stream, Cancellable? cancellable = null) throws Error
Outputs JSON data and writes it (synchronously) to the given stream.
Inherited Members:
All known members inherited from class GLib.Object