| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
| |
The json-scanner.h header file is not shipped with JSON-GLib anymore.
|
|
|
|
|
| |
Fix a distcheck error because json-scanner.h is not packaged inside
the tarball.
|
|
|
|
|
|
|
|
|
| |
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).
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
When including json-glib/json-glib.h we get everything json-glib
expose as a public symbol.
|
|
|
|
|
| |
The enumeration GTypes are public and meant to be used by
language bindings and other users of the library.
|
| |
|
|
|
|
|
| |
The templates for glib-mkenums keep the Makefile.am sane and
editable by mere mortals.
|
| |
|
| |
|
|
|
|
|
| |
If the source JsonNode does not contain data yet, do not try
and copy it.
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
| |
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 branch 'master' into json-scanner
|
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| | |
Test the GValue API for storing fundamental types into a JsonNode.
|
| |
| |
| |
| |
| | |
Use a similar test unit as the JsonArray one, testing creation, empty
objects, addition and removal of members.
|
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| | |
This simple unit will test the JsonArray API, as part of the coverage
test for the JSON-GLib types.
|
| |
| |
| |
| |
| | |
The test unit copies a NULL JsonNode and checks that the copy and the
original nodes are equivalent.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| | |
Use a closure instead of (*eugh*) an array of gpointers and casting
to void*.
Also, use the Slice allocator for the ScannerKey structs.
|
| |
| |
| |
| | |
JsonParser now uses JsonScanner, the internal copy of GScanner.
|
| |
| |
| |
| |
| | |
Rename all the API and the data types to the Json namespace, so we can
use the internal copy instead of GScanner.
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| |
| | |
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.
|
| | |
|
| | |
|
| |
| |
| |
| | |
The GTokenType extension enumeration belongs with the tokenizer.
|
|/
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
Do not free the root node returned by the get_root() method in the
JSON-GObject API and in the JsonParser tests.
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
The json_object_has_member() used the passed in member name, instead of
the correctly normalized one.
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
Including the autotools generated config.h should always be conditional
on the HAVE_CONFIG_H definitions.
|
|
|
|
| |
Use an intermediary pointer to avoid a lot of pointer dereferences
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
Avoid feeding garbage to the callers by using g_slice_new0().
|
|
|
|
| |
Found this very dumb leak while using Valgrind.
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
Update json_construct_gobject() to the change of behaviour in the
root node getter function of JsonParser.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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().
|
|
|
|
|
| |
The indent character should be any Unicode character available instead
of a generic char.
|
|
|
|
|
| |
The JsonGenerator:indent-char can be used to control the character that
indents the lines when pretty printing.
|
|
|
|
|
| |
JsonNode of type value for floating point numbers is G_TYPE_DOUBLE
and not G_TYPE_FLOAT anymore.
|
|
|
|
|
|
|
|
| |
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.
|