Parser


Object Hierarchy:

Object hierarchy for Parser

Description:

[ CCode ( type_id = "json_parser_get_type ()" ) ]
public class Parser : Object

`JsonParser` provides an object for parsing a JSON data stream, either inside a file or inside a static buffer.

Using `JsonParser`

The `JsonParser` API is fairly simple:

```c gboolean parse_json (const char *filename) { g_autoptr(JsonParser) parser = json_parser_new (); g_autoptr(GError) error = NULL

json_parser_load_from_file (parser, filename, &error); if (error != NULL) { g_critical ("Unable to parse ' s': s", filename, error->message); return FALSE; }

g_autoptr(JsonNode) root = json_parser_get_root (parser);

// manipulate the object tree from the root node

return TRUE } ```

By default, the entire process of loading the data and parsing it is synchronous; the [method@Json.Parser.load_from_stream_async] API will load the data asynchronously, but parse it in the main context as the signals of the parser must be emitted in the same thread. If you do not use signals, and you wish to also parse the JSON data without blocking, you should use a `GTask` and the synchronous `JsonParser` API inside the task itself.


Namespace: Json
Package: json-glib-1.0

Content:

Properties:

Creation methods:

Methods:

Signals:

Inherited Members: