summaryrefslogtreecommitdiff
path: root/json-glib/json-reader.c
diff options
context:
space:
mode:
authorFrederic Martinsons <frederic.martinsons@sigfox.com>2022-09-10 08:44:40 +0200
committerFrederic Martinsons <frederic.martinsons@sigfox.com>2022-10-11 15:21:11 +0200
commit39e6a1f5ccd25abba5b2f618cec772b24f40085f (patch)
treecba0aa5f1dff9a4159ec1fdbe12ad0b3ae89ab5b /json-glib/json-reader.c
parenteeb508e64577d6123875b4fb6d7684b87555f10a (diff)
downloadjson-glib-39e6a1f5ccd25abba5b2f618cec772b24f40085f.tar.gz
Add new api json_reader_get_current_node
This can be useful to extract a sub json structure during parsing of another (for example when we don't know in advance the format of this sub json and just want to pass it to another consumer). Closes #9 Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
Diffstat (limited to 'json-glib/json-reader.c')
-rw-r--r--json-glib/json-reader.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/json-glib/json-reader.c b/json-glib/json-reader.c
index cc10cc8..3e58853 100644
--- a/json-glib/json-reader.c
+++ b/json-glib/json-reader.c
@@ -1117,3 +1117,22 @@ json_reader_get_member_name (JsonReader *reader)
return g_ptr_array_index (reader->priv->members,
reader->priv->members->len - 1);
}
+
+/**
+ * json_reader_get_current_node:
+ * @reader: a reader
+ *
+ * Retrieves the reader node at the current position.
+ *
+ * Return value: (nullable) (transfer none): the current node of the reader
+ *
+ * Since: 1.8
+ */
+JsonNode *
+json_reader_get_current_node (JsonReader *reader)
+{
+ g_return_val_if_fail (JSON_IS_READER (reader), NULL);
+ json_reader_return_val_if_error_set (reader, NULL);
+
+ return reader->priv->current_node;
+}