summaryrefslogtreecommitdiff
path: root/json-glib/json-parser.h
Commit message (Collapse)AuthorAgeFilesLines
* Update the JsonParser documentationEmmanuele Bassi2021-06-101-1/+6
|
* docs: Initial, rough port away from gtk-docEmmanuele Bassi2021-06-081-7/+1
| | | | | | | | | | Drop `SECTION` blurbs. Use gi-docgen syntax for internal links. Use summary lines for gi-docgen indices. Use Markdown syntax for code fragments.
* json-parser: Support loading files via memory mappingPhilip Withnall2020-06-091-0/+4
| | | | | | | | | | | | | | | Add a new `json_parser_load_from_mapped_file()` to load JSON from files via memory mapping. It’s otherwise similar to `json_parser_load_from_file()`. It’s in the right position to be able to memory map the file it’s reading from: it reads the input once before building a `JsonNode` structure to represent it, doesn’t write to the file, and often deals with large input files. This should speed things up slightly due to reducing time spent allocating a large chunk of heap memory to load the file into, if a caller can support that. Signed-off-by: Philip Withnall <withnall@endlessm.com>
* core: Add json_parser_steal_root()Ole André Vadla Ravnås2017-03-181-0/+2
| | | | | | This avoids copying the root node for the parse-to-node use-case. https://bugzilla.gnome.org/show_bug.cgi?id=774688
* core: Add immutability support to core objectsPhilip Withnall2016-03-011-0/+2
| | | | | | | | | | | Add an immutable mode to JsonNode, JsonObject, JsonArray and JsonValue. This is an optional mode which objects enter by calling json_*_seal(). It is a one-way transition, which means that we can build and manipulate objects as much as desired, before sealing them and enjoying the benefits of immutable objects: no need to take copies when handling them, persistent hash values (still to be implemented). https://bugzilla.gnome.org/show_bug.cgi?id=756121
* Add autoptr macrosEmmanuele Bassi2016-02-291-0/+4
| | | | | | | GLib can take advantage of the "cleanup" attribute by using a bunch of macro magic. This has been slowly been used across various libraries in the G* stack, so JSON-GLib should provide symbols for the automatic memory management of its types.
* Use compiler annotations to determine symbol visibilityEmmanuele Bassi2014-03-181-1/+12
| | | | | | | | | | | | | | | | | Instead of relying on a separate file that requires being update every time we add a new public function we should use compiler annotations to let the linker know which symbols are public and exported. In order to achieve this we have to: * check for the visibility=hidden attribute * add -fvisibility=hidden to the linker flags * add a macro to annotate all public symbols While we're at it, we should copy the versioned symbols macro layout already used by GLib, GTK+, and other G* libraries, including the ability to express the range of allowed versions of JSON-GLib that third party code can compile against.
* Move the single include guard after multiple inclusion oneEmmanuele Bassi2013-12-041-3/+3
| | | | | | | | | | | | | | GCC (and other compilers) can optimise multiple inclusion of headers if they find the: #ifndef FOO #define FOO #endif pattern as the first thing inside a header. The single-header inclusion guard was preventing that from happening, so we need to move it inside the multiple inclusion guard.
* parser: Always perform UTF-8 validationEmmanuele Bassi2013-10-271-0/+2
| | | | | | JSON is defined to be encoded using UTF-8, so we should not rely on the documentation saying so when parsing, but validate the input and eventually provide a recoverable parsing error.
* parser: Empty member names are not validEmmanuele Bassi2012-10-261-1/+3
| | | | | When parsing a JSON object, a member name has to be a valid string, not an empty one.
* Fix the include for json-types.hEmmanuele Bassi2010-08-021-1/+1
|
* parser: Add loading from a GInputStreamEmmanuele Bassi2010-08-021-18/+31
| | | | | JsonParser should be able to use a GInputStream (both synchronously and asynchronously) to retrieve the JSON data and parse it.
* docs: Fix typo in JsonParserError annotationEmmanuele Bassi2010-04-141-1/+1
|
* parser: Add MISSING_COLON errorEmmanuele Bassi2010-03-191-0/+2
| | | | | | We identify a missing ':' separator between an object member name and its value, so it would be a good thing to actually have an error code for that.
* parser: Return specific error codesEmmanuele Bassi2010-03-191-0/+8
| | | | | | | | | The JsonScanner error reporting mechanism, which is basically GScanner's, sucks beyond belief. In order to report an error code we need to store it inside the JsonParser private structure and then use it when creating the GError inside the error handler. This, frankly, is quite stupid.
* Disallow single header file inclusionEmmanuele Bassi2009-08-121-0/+4
| | | | | | | | | The correct header file for JSON-GLib is, and has always been, json-glib.h. Anything else was not supported, as we've been moving around stuff for a while, now. This commit enforces the single include file, using the same policy enacted by other libraries, like: GLib, GTK+ and Clutter.
* Fix license and copyright noticesEmmanuele Bassi2009-06-091-2/+6
| | | | | | | | THere is no such thing as the "Lesser General Public License version 2": the LGPL v2 is the "Library GPL", and has been superceded by v2.1 with the new "Lesser GPL" name. Also, the copyright is now Intel Corp.
* Move JsonTokenType into JsonScannerEmmanuele Bassi2008-02-291-13/+2
| | | | The GTokenType extension enumeration belongs with the tokenizer.
* Revert JsonParser::get_root semanticsEmmanuele Bassi2008-01-291-1/+0
| | | | | | | | | The get_root() method should not return a copy of the parsed node: it is up to the developer copying it, if it needs to be kept around across multiple parsing runs. This commit reverts the 0b6b09c0 commit, by removing the peek_root() method and restoring the previous get_root() method behaviour.
* Use gssize for the buffer length parameterEmmanuele Bassi2007-12-251-1/+1
| | | | | | | Since we allow a negative value, meaning "take the whole string", for the length parameter, when need a signed size_t. This also fixes the bug where we implicitly always computed the buffer length and discarded the passed length parameter.
* Change json_parser_get_root() semanticsEmmanuele Bassi2007-11-211-0/+2
| | | | | | | | | | | | | The json_parser_get_root() returns a pointer to the root node. This does not conform to the API naming convention inherited from GLib, where functions returning an internal pointer are called "peek" and function returning a copy are called "get". Thus, json_parser_get_root() will now return a copy of the root node and it is left to the developer to free the returned JsonNode. A function returning the pointer has also been added, and it's called json_parser_peek_root().
* Add support for parsing assignmentsEmmanuele Bassi2007-11-101-0/+5
| | | | | | | | | | | | | | | | | Some JSON web APIs return a full JavaScript assignment instead of just the data structure (and I'm looking at you, Tumblr). This is done in clear violation of the grammar published in the RFC 4627, and it's evidently done because most web developers are too lazy for doing a var foo = eval('(' + text ')'); and want everything defined for them. JsonParser will blissfully ignore the left-hand part of the assignment but, in the interest of the developer who cares, will record: 1. that the parsed statement was in fact an assignment and 2. the name of the variable used. The function json_parser_has_assignment() can be used to query both the presence of an assignment and the variable name at the same time.
* Add line/position getters to JsonParserEmmanuele Bassi2007-10-051-9/+12
| | | | | | Add two methods to JsonParser to retrieve the currently parsed line and position within that line. These methods works only while parsing, so within the signal handlers and inside subclasses.
* Document the newly added signalsEmmanuele Bassi2007-10-051-1/+9
|
* Add more signals to the JsonParser classEmmanuele Bassi2007-10-051-3/+22
| | | | | | | JsonParser should emit signals in critical places, like: start/end of the parsing process; start and end of a JsonObject and a JsonArray; completion of every member and element of a JsonObject and a JsonArray. These signals require the addition of some custom marshaller.
* Complete API reference of JSON-GLibEmmanuele Bassi2007-10-011-0/+19
| | | | With this commit, we reach 100% coverage.
* Add licensing informations to the source codeEmmanuele Bassi2007-10-011-0/+19
|
* Add JsonNode, a generic container for JSON typesEmmanuele Bassi2007-10-011-1/+1
| | | | | | | | | | | | | | | | | This huge commit removes JsonData and adds JsonNode, the generic container for fundamental and complex data types extracted from a JSON stream. The contents of a JsonNode can be extracted from it in form of a GValue for fundamental types (integers, floats, strings, booleans) or in form of JsonObject and JsonArray objects. JsonObject and JsonArray now accept JsonNodes instead of GValues. The JsonParser object builds the data model tree when parsing a JSON stream; the tree can be recursed by getting the root node and walking it using the GValue API for the fundamental types and the objects/arrays API for complex types. The API has been updated and the tests now recurse through the generated data model tree.
* Add stubs to JsonParser for actually parsing a JSON streamEmmanuele Bassi2007-09-211-3/+25
| | | | | | | | | | | | | | | | | Initial commit for getting JsonParser to work. Because GScanner API is old and mostly sucks, we need to do some magic with signals. If json_parser_load_from_data() fails, the passed GError will be set with a JSON_PARSER_ERROR code and message; unfortunately, we can't get the nice error message out of GScanner. We can, however, override the default message handler and make it emit a signal on the JsonParser object. So, to make a long story short: the GError passed to the load_from_data() method is filled with a short error message; the *real* error message is passed to the ::error signal handlers so they can actually use it. GScanner should really get a way to retrieve the last error message.
* Initial import of JSON-GLibEmmanuele Bassi2007-09-201-0/+57
JSON-GLib is a JSON parser library written with GLib and GObject. JSON is the JavaScript Object Notation, and it's used to define objects and object hierarchies in a human-readable way.