summaryrefslogtreecommitdiff
path: root/json-glib
Commit message (Collapse)AuthorAgeFilesLines
* Escape to special characters in JsonGeneratorbug-958Emmanuele Bassi2008-06-131-1/+16
| | | | | | | | | | | | When using json-glib to write a blog system, some deserialized objects were not been interpreted by javascript because there were line breaks in generated strings. Patch from Lincoln de Sousa. Bug #958 - JsonGenerator does not escape special characters Signed-off-by: Emmanuele Bassi <ebassi@openedhand.com>
* Remove the include for json-scanner.hEmmanuele Bassi2008-05-181-1/+0
| | | | The json-scanner.h header file is not shipped with JSON-GLib anymore.
* Add json-scanner.h to the EXTRA_DIST contentEmmanuele Bassi2008-05-051-0/+1
| | | | | Fix a distcheck error because json-scanner.h is not packaged inside the tarball.
* Use an array to hold the strings in a vectorEmmanuele Bassi2008-05-011-10/+5
| | | | | | | | | Instead of building a GString by concatenating every string inside an array to deserialize the array into a string vector property, use a GPtrArray. This is far more efficient (no reallocations are necessary, as we know the size of the array) and safe (the separator used to build the string buffer and then split it might exist in one of the original strings).
* Export only the public symbolsEmmanuele Bassi2008-04-241-1/+5
| | | | | | All the symbols starting with an underscore or with something that is not "json" are to considered private, and thus are not global to the shared object.
* Include the newly added json-enum-types.h headerEmmanuele Bassi2008-04-241-0/+1
| | | | | When including json-glib/json-glib.h we get everything json-glib expose as a public symbol.
* Install the autogenerated enum types headerEmmanuele Bassi2008-04-241-0/+1
| | | | | The enumeration GTypes are public and meant to be used by language bindings and other users of the library.
* Autogenerate the GTypes for the enumerationsEmmanuele Bassi2008-04-241-23/+47
|
* Add enumeration types templates for glib-mkenumsEmmanuele Bassi2008-04-242-0/+57
| | | | | The templates for glib-mkenums keep the Makefile.am sane and editable by mere mortals.
* Whitespace fixes in the licensing noticeEmmanuele Bassi2008-04-191-1/+1
|
* Documentation fixes in JsonNodeEmmanuele Bassi2008-04-191-3/+3
|
* Do not copy node data if it's not thereEmmanuele Bassi2008-04-191-4/+13
| | | | | If the source JsonNode does not contain data yet, do not try and copy it.
* Do not install the JsonScanner headerEmmanuele Bassi2008-04-191-2/+3
| | | | | | The JsonScanner tokenizer is an internal copy of GScanner: it should not be used outside JSON-GLib - JsonParser is the public API for parsing JSON.
* Add support for parsing \uXXXX into UnicodeEmmanuele Bassi2008-04-191-6/+50
| | | | | | | | | | | | JsonScanner was forked from GScanner in order to support the JSON-specific Unicode escaping. JsonScanner now intercepts the \u escape character and, if it is followed by a hexadecimal value, it will retrieve the Unicode character encoded in the following 4 values and insert the character itself in the buffer. This allows full compatibility with JSON.
* Merge master branch back for testing JsonScannerEmmanuele Bassi2008-04-196-7/+242
|\ | | | | | | Merge branch 'master' into json-scanner
| * Allow null nodes to return a value without a warningEmmanuele Bassi2008-04-121-6/+15
| | | | | | | | | | | | Value nodes might contain 'null' as a valid value, so the fast accessors should not barf out when encountering a JSON_NODE_NULL instead of the expected JSON_NODE_VALUE.
| * Add value testing to the JsonNode unitEmmanuele Bassi2008-03-091-0/+29
| | | | | | | | Test the GValue API for storing fundamental types into a JsonNode.
| * Add JsonObject test unitEmmanuele Bassi2008-03-052-6/+73
| | | | | | | | | | Use a similar test unit as the JsonArray one, testing creation, empty objects, addition and removal of members.
| * Add element removal unit to the Array testEmmanuele Bassi2008-03-051-0/+12
| | | | | | | | | | | | Remove the json_array_remove_element() call from the add-element test unit and set up a separate test case for the element removal. This keeps the test cases clean.
| * Add array-test to the JSON-GLib types unit testsEmmanuele Bassi2008-03-022-3/+57
| | | | | | | | | | This simple unit will test the JsonArray API, as part of the coverage test for the JSON-GLib types.
| * Add a JsonNode copy test unitEmmanuele Bassi2008-03-021-0/+15
| | | | | | | | | | The test unit copies a NULL JsonNode and checks that the copy and the original nodes are equivalent.
| * Add initial test suite support using GLib's new testing frameworkEmmanuele Bassi2008-03-013-1/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | GLib 2.15 added a new test unit framework to the GLib API. It allows integrating unit testing into GLib and GObject based libraries and applications. It requires a specially crafter Makefile holding a set of declarations, which must be included into the project own Makefile templates; then it is possible to drop tests inside a subdirectory, which will be built after the library or application, and executed upon "make check". At the moment, there is a simple test for the JsonNode API, with a single unit for the "null" node type.
* | Sanitize JsonScanner codeEmmanuele Bassi2008-02-291-22/+20
| | | | | | | | | | | | | | Use a closure instead of (*eugh*) an array of gpointers and casting to void*. Also, use the Slice allocator for the ScannerKey structs.
* | Update JsonParser to fix compilationEmmanuele Bassi2008-02-291-16/+17
| | | | | | | | JsonParser now uses JsonScanner, the internal copy of GScanner.
* | Completely internalize the JsonScannerEmmanuele Bassi2008-02-292-317/+328
| | | | | | | | | | Rename all the API and the data types to the Json namespace, so we can use the internal copy instead of GScanner.
* | Add JsonScanner to the buildEmmanuele Bassi2008-02-291-0/+2
| |
* | Update the JsonScanner default configurationEmmanuele Bassi2008-02-291-48/+36
| |
* | Use JsonScanner API into JsonParserEmmanuele Bassi2008-02-291-83/+44
| | | | | | | | | | | | | | Rename the GScanner function calls into JsonScanner, to see what we actually need to have public. Also, remove the configuration: JsonScanner will provide us with one.
* | Add json-scanner.h to the exported headersEmmanuele Bassi2008-02-291-0/+1
| |
* | Include JsonScanner into JsonParserEmmanuele Bassi2008-02-291-0/+1
| |
* | Move JsonTokenType into JsonScannerEmmanuele Bassi2008-02-291-13/+2
| | | | | | | | The GTokenType extension enumeration belongs with the tokenizer.
* | Copy GScanner into JSON-GLib as JsonScannerEmmanuele Bassi2008-02-292-0/+1976
|/ | | | | | | | | | | | | Instead of writing our tokenizer we can fork GScanner and make a specialized version for JSON (as per RFC), luckily the licenses are compatible (LGPLv2.1 with "any later" clause). GScanner does not support Unicode "\uNNNN" escaping and we need to ensure UTF-8 strings as well. The API will mostly be the same, but the generic bits not used by JsonParser will be hidden: this is, after all, a specialized tokenizer.
* Update after the JsonParser::get_root changeEmmanuele Bassi2008-01-291-3/+1
| | | | | Do not free the root node returned by the get_root() method in the JSON-GObject API and in the JsonParser tests.
* Revert JsonParser::get_root semanticsEmmanuele Bassi2008-01-292-25/+2
| | | | | | | | | 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 the normalized member name in has_memberEmmanuele Bassi2008-01-281-1/+1
| | | | | The json_object_has_member() used the passed in member name, instead of the correctly normalized one.
* Extract the parser state clearing into its own functionEmmanuele Bassi2008-01-271-21/+30
| | | | | | | | The JsonParser object clears its state upon starting the parsing sequence or during the instance destruction process. It's worth moving the free and unref calls into their own function to be called by the load_from_data() and dispose methods. As further optimisation, inlining them should be worth as well.
* Wrap config.h include with conditionalsEmmanuele Bassi2007-12-255-0/+11
| | | | | Including the autotools generated config.h should always be conditional on the HAVE_CONFIG_H definitions.
* Kill off a few indirectionsEmmanuele Bassi2007-12-251-11/+14
| | | | Use an intermediary pointer to avoid a lot of pointer dereferences
* Provide a default implementation of JsonSerializableEmmanuele Bassi2007-12-251-88/+120
| | | | | | | | The JsonSerializable interface can provide a default implementation, using the powers of GTypeInterface. This means that classes implementing the interface can opt to implement both, either or none of the JsonSerializable methods, and still be able to retain some basic functionality for the methods they decide not to implement.
* Plug a leak when loading a new buffer with the same parserEmmanuele Bassi2007-12-251-0/+2
| | | | | | When the same JsonParser loads a different buffer it needs to clear out the current state; this means clearing the variable_name string it saves when the passed JSON stream is a JavaScript assignment.
* Use gssize for the buffer length parameterEmmanuele Bassi2007-12-252-6/+6
| | | | | | | 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.
* Initialise to zero when creating/copying a JsonNodeEmmanuele Bassi2007-12-251-4/+5
| | | | Avoid feeding garbage to the callers by using g_slice_new0().
* Do not leak the intermediate strings when generating JSONEmmanuele Bassi2007-12-251-0/+6
| | | | Found this very dumb leak while using Valgrind.
* Add API to retrieve copies of the nodes inside objects and arraysEmmanuele Bassi2007-11-213-0/+62
| | | | | | Getting copies of the nodes might work better for high level languages binding the JSON-GLib API, because they can manage the lifetime of the returned values using their own rules.
* Free the root node obtained using json_parser_get_root()Emmanuele Bassi2007-11-211-0/+2
| | | | | Update json_construct_gobject() to the change of behaviour in the root node getter function of JsonParser.
* Change json_parser_get_root() semanticsEmmanuele Bassi2007-11-212-2/+26
| | | | | | | | | | | | | 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().
* Use a unicode character for the indent-char property of JsonGeneratorEmmanuele Bassi2007-11-211-8/+8
| | | | | The indent character should be any Unicode character available instead of a generic char.
* Add the indent-char property to JsonGeneratorEmmanuele Bassi2007-11-211-14/+40
| | | | | The JsonGenerator:indent-char can be used to control the character that indents the lines when pretty printing.
* Use G_TYPE_DOUBLE when dumping a value.Emmanuele Bassi2007-11-211-2/+2
| | | | | JsonNode of type value for floating point numbers is G_TYPE_DOUBLE and not G_TYPE_FLOAT anymore.
* Allow deserialization of strings into enums/flagsEmmanuele Bassi2007-11-201-0/+170
| | | | | | | | If the target value is a G_TYPE_ENUM or a G_TYPE_FLAGS we can effectively deserialize a string into the corresponding value (or bit mask) using the introspection API for the GEnum and GFlags types. This code is taken from ClutterScript and it was adapted from GtkBuilder.