summaryrefslogtreecommitdiff
path: root/json-glib/json-path.c
Commit message (Collapse)AuthorAgeFilesLines
* path: Pass int width for printf field width, not longColin Walters2012-06-081-4/+4
|
* Mark GError messages for translationsEmmanuele Bassi2011-06-011-6/+7
| | | | These errors might find their way into a UI.
* Add i18n machineryEmmanuele Bassi2011-06-011-1/+3
| | | | We need to translate the GError messages.
* Revert "path: Add some more validation points"Emmanuele Bassi2011-06-011-56/+21
| | | | | | This reverts commit e8fa85705e48d03742eb351addbad53be4d8e60b. The validation broke the test suite; it'll need some more work.
* path: Add some more validation pointsEmmanuele Bassi2011-06-011-21/+56
| | | | Especially for the slice syntax.
* docs: Document JsonPath and add it to the API referenceEmmanuele Bassi2011-06-011-2/+172
|
* Add initial JSONPath implementationEmmanuele Bassi2011-05-311-0/+856
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.