summaryrefslogtreecommitdiff
path: root/json-glib/json-debug.c
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2011-05-28 14:36:43 +0100
committerEmmanuele Bassi <ebassi@linux.intel.com>2011-05-31 23:02:35 +0100
commit4ea8cd43986d5888fb8e809a198d6b0331b12480 (patch)
treef3253bf151093e26285c082ddabf72a079efc857 /json-glib/json-debug.c
parent8b778252358ddb28936c6c9192a84f76368ca122 (diff)
downloadjson-glib-4ea8cd43986d5888fb8e809a198d6b0331b12480.tar.gz
Add initial JSONPath implementation
JSONPath is a JSON query syntax similar to what XPath does for XML; using JSONPath it's possible to address a specific node (or set of nodes) inside a JSON document. The JsonPath class is a simple implementation of part of the JSONPath proposal, as formalised by Stefan Gössner here: http://goessner.net/articles/JsonPath/ The covered operators are: • root, or '$'; • child, both using the dot-notation and the bracket notation; • recursive descent, or '..'; • subscript, or '[]'; • set, or '[,]'; • slice, or '[start:end:step]'. The only missing operators are the filter, or '?()' and the script, or '()', because implementing a JavaScript interpreter inside JSON-GLib is not one of my greatest aspirations. It should be possible, though, to parse and evaluate simple arithmetic conditions, in the future. The JsonPath methods are pretty straightforward: a JsonPath instance should be created and used to compile an expression; the compilation might result in a syntax error or not. Then, the JsonPath instance can be used to match any JSON tree. Like the other JSONPath implementations, JsonPath returns a JSON array of matching nodes. A simple, one-off static method called json_path_query() is also provided; the method wraps the JsonPath creation, the expression compilation, and the matching, as well as disposing the JsonPath instance once done. For the time being, only positive testing is provided; negative testing for the expression compilation will follow.
Diffstat (limited to 'json-glib/json-debug.c')
-rw-r--r--json-glib/json-debug.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/json-glib/json-debug.c b/json-glib/json-debug.c
index dd725c4..c0dc2e9 100644
--- a/json-glib/json-debug.c
+++ b/json-glib/json-debug.c
@@ -10,7 +10,8 @@ static gboolean json_debug_flags_set = FALSE;
#ifdef JSON_ENABLE_DEBUG
static const GDebugKey json_debug_keys[] = {
{ "parser", JSON_DEBUG_PARSER },
- { "gobject", JSON_DEBUG_GOBJECT }
+ { "gobject", JSON_DEBUG_GOBJECT },
+ { "path", JSON_DEBUG_PATH }
};
#endif /* JSON_ENABLE_DEBUG */