| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
| |
There's no point in having the API reference in its own sub-directory:
it's the only documentation we have.
|
| |
|
|
|
| |
The API reference should list the header that user code should include
in order to use the API.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Now that these objects can be marked as immutable, it is possible to
calculate and cache hash values for each of them. This allows efficient
hash-based deduplication of large numbers of JSON nodes, as needed by
Walbottle for JSON test vector generation.
To complement the new hash functions, each of JsonNode, JsonValue,
JsonObject and JsonArray also now have an equal() comparison method.
This compares them structurally and recursively, using the definition of
equality from the JSON Schema specification, which seems as good as any
other.
http://json-schema.org/latest/json-schema-core.html#anchor9
https://bugzilla.gnome.org/show_bug.cgi?id=756121
Signed-off-by: Emmanuele Bassi <ebassi@gnome.org>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add reference counting semantics to JsonNode, in addition to the
existing init/unset and alloc/free semantics.
json_node_free() must only be used with nodes allocated using
json_node_alloc(). json_node_unref() may be used with all nodes (if
correctly paired; it may be paired with json_node_alloc()).
It is not valid to call json_node_free() on a node whose reference count
is not 1.
https://bugzilla.gnome.org/show_bug.cgi?id=756121
|
| |
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
| |
This is a stack-allocated iterator object similar to GHashTableIter
which allows allocation-free iteration over the members in a JsonObject.
It differs from json_object_foreach_member() in the order in which it
iterates — for JsonObjectIter the order is undefined.
https://bugzilla.gnome.org/show_bug.cgi?id=755509
|
| | |
|
| |
|
|
|
| |
Wrap JsonParser and JsonGenerator in simple, easy to call functions that
manage the objects for you.
|
| |
|
|
| |
Add a JSON_ENCODE_VERSION macro and use it in JSON_VERSION_HEX.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
| |
We should simplify the JsonNode API a bit, especially when it comes to
initializing nodes. Instead of a two-step "new(<type>) followed by a
set_<type>(value)" API, we can provide a "init_<type>(value)" API that
can take any existing JsonNode and initialize it to the given type.
This makes the JsonNode creation more concise and reliable; it also
allows to implicitly re-initialize JsonNodes without requiring the user
to de-allocate/re-allocate them first.
|
| |
|
|
| |
The deprecation macros should be in the private section.
|
| | |
|
| | |
|
| |
|
|
| |
This should allow easy access to the member name during iteration.
|
| |
|
|
|
| |
Allow retrieving a list of member names from the current cursor position
of the JsonReader. It's useful if you're trying to inspect a JSON tree.
|
| |
|
|
| |
https://bugzilla.gnome.org/show_bug.cgi?id=632940
|
| |
|
|
|
|
|
|
| |
Instead of asking everyone to use g_object_set() to set up a
JsonGenerator the class should provide a decent API for its properties.
While we're at it, we should also use modern API for installing and
notifying of property changes.
|
| |
|
|
|
|
|
| |
Since JsonParser has far more methods for parsing a JSON stream we
should just make JsonReader an API for reading an already parsed JSON
tree - in the same way that JsonBuilder does not generate the
stringified version of the JSON tree it builds.
|
| |
|
|
| |
We should strive to make JsonBuilder and JsonReader similar in API.
|
| | |
|
| |
|
|
|
|
|
| |
Currently, only synchronous API.
The output handling is pretty trivial, unlike the input handling in
JsonParser; this is a really basic convenience API.
|
| | |
|
| |
|
|
|
| |
And silence gtk-doc-scanner by removing an undefined argument from
json_builder_add_null_value().
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A GBoxed type defined as:
struct Boxed {
int foo;
gboolean bar;
int baz;
};
Can be represented either by a JSON object:
{
"foo" : 1,
"bar" : true,
"baz" : 3
}
Or by a JSON array:
[ 1, true, 3 ]
The current function for registering a serialization and a
deserialization pair does not allow registering more than one
deserialization function - which means that there can only be
one way to deserialize a GBoxed type into a specific JsonNode
type.
To allow having more than one JsonNodeType associated to a
GBoxed type and a deserialization function we need to split out
the registration of the serialization and deserialization functions
into two distinct functions.
|
| |
|
|
|
|
|
|
|
|
| |
If you want to use the default implementation of serialize_property()
and/or deserialize_property() from an object class implementing
JsonSerializable you currently have to peek the interface vtable and
then call the vfunc pointers.
We can expose the default implementation through functions ourselves and
simplify the required code.
|
| |
|
|
|
|
|
|
|
| |
Rename json_gobject_new() to json_gobject_deserialize(), and
json_gobject_dump() to json_gobject_serialize(); this maps the
JSON GBoxed API.
Also for consistency, change the serialize() return value and
the deserialize() argument to be JsonNodes of type JSON_NODE_OBJECT.
|
| |
|
|
|
|
|
|
|
| |
Like commit c176f70e593c9cfb4901cd9f27ce54b8aa7152f2 did for the
source code, the documentation should be split three-ways:
• GObject-related API
• JsonSerializable
• GBoxed-related API
|
| |
|
|
| |
JsonNode should mimick GValue's API and have macros for easy type checking
|
| |
|
|
|
| |
Add the setter for JsonNode:parent, to be used in JsonParser instead
of directly accessing the JsonNode structure.
|
| |
|
|
|
|
| |
Similarly to commit 3057a172 for JsonObject, the newly added
json_array_foreach_element() iterates over a JSON array data
type.
|
| |
|
|
|
| |
The json_object_foreach_member() function iterates over a JsonObject
data type.
|
| |
|
|
|
| |
The json_node_is_null() function is just a quick check for
nodes set to null.
|
| |
|
|
|
| |
First pass at adding some type safety to the JsonNode type checks,
and at removing every mention of the JsonNode interna fields.
|
| |
|
|
|
|
|
|
|
|
| |
Like commit 5bb6ea91 did for JsonObject, we should add typed
convenience accessors to JsonArray in order to cut down the
amount of nodes needed when parsing and generating JSON data
streams.
As for JsonObject, the amount of types is small enough to avoid
the combinatorial API explosion.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The add_member() method of JsonObject has wee bit weird semantics: if
the member to be added already exists it prints a scary warning and
returns - and yet it calls g_hash_table_replace() internally as if it
overwrites the member.
So, instead of changing semantics midway we can:
- add a json_object_set_member() which adds a new member and
overwrites existing members
- deprecate json_object_add_member()
While we're at it, we can add convenience wrappers for set_member()
and get_member() that don't require us toying with nodes; luckily,
since the amount of valid types we can add to a JsonObject is limited,
this does not lead to a combinatorial API explosion.
|
| |
|
|
|
|
|
|
|
| |
When generating the documentation, ignore the JsonScanner header
as it will not be installed.
Also, we moved JsonTokenType from json-parser.h to json-scanner.h,
where it belongs, so we can remove it from the (private) subsection
of the json-parser section.
|
| |
|
|
|
| |
The json_parser_peek_root() function has been removed, and so we do not
its symbol in the json-glib-sections.txt file anymore.
|
| | |
|
| | |
|
| |\ |
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The json_construct_gobject() function takes a GType and a JSON data stream
and constructs a new instance for the given type. If the type is a
JsonSerializable, it will use the JsonSerializable interface for parsing
the JsonNodes of each object member.
This is the initial implementation of the function: the JsonNode-to-GValue
fallback parser is just a stub.
|
| |/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
| |
The JsonSerializable interface allows implementations to override the
GObject-to-JSON serialization process, by providing two virtual methods
to control the (de)serialization of GObject properties. This way it's
possible to serialize GObjects with properties holding complex data types.
|
| |
|
|
|
| |
To map json_array_get_elements(), a json_object_get_values() method has
been added which returns the list of JsonNodes contained by a JsonObject.
|
| |
|
|
|
|
|
| |
Write and document json_object_remove_member() and json_array_remove_element()
which can be used to remove a JsonNode from a JsonObject or a JsonArray
respectively. This way, the JsonObject and JsonArray are API-complete and
the object model can be manipulated in code.
|
| |
|
|
|
| |
The newly added json_node_dup_string() is a convenience function for
getting a copy of the string contained inside a JsonNode.
|
| |
|
|
|
|
| |
This commit adds some convenience accessors for setting and
getting fundamental types in and from a JsonNode, to avoid
jumping through all the GValue hoops.
|
| |
|
|
|
|
| |
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.
|