| Commit message (Collapse) | Author | Age | Files | Lines |
|\
| |
| |
| |
| | |
set node->data pointer to null when unset
See merge request GNOME/json-glib!37
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
|/
|
|
|
|
|
|
|
|
| |
Drop `SECTION` blurbs.
Use gi-docgen syntax for internal links.
Use summary lines for gi-docgen indices.
Use Markdown syntax for code fragments.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Despite my efforts in commit 011c1e424b7 (parts of which were completely
incorrect), the JsonNode documentation still wasn’t particularly helpful
about differentiating between methods which return NULL if the JsonNode
is not of the right type, and methods which emit a critical warning.
Try and improve that across the board, hopefully without saying
blatantly incorrect things this time.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Clarify in the documentation what each of the JsonNode getters when
called on a node which contains a value whose type is not what the
caller expects (since this behaviour is well-defined in the code).
Add relevant (nullable) annotations too.
Inspired by http://stackoverflow.com/q/42081921/2931197.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
https://bugzilla.gnome.org/show_bug.cgi?id=779464
|
|
|
|
|
| |
This allows conditional compilation, and it makes the debugging code
consistent.
|
|
|
|
| |
The newly added API is available since 1.2.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
| |
Clarify the documentation for json_node_set_object() and
json_object_get_array_member().
https://bugzilla.gnome.org/show_bug.cgi?id=754384
|
|
|
|
| |
All the platforms and build system we support have a config.h header.
|
|
|
|
|
| |
Drop the DocBook documentation, and move everything to the MarkDown
format used by modern gtk-doc.
|
|
|
|
|
| |
JsonNode, JsonObject, and JsonArray have various constructors, so we
need to annotate them.
|
|
|
|
| |
https://bugzilla.gnome.org/show_bug.cgi?id=693575
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
When retrieving an int, a double, or a boolean, we can use the C rules
of implicit conversion to move from the actual stored type inside the
JsonValue to the requested C type.
https://bugzilla.gnome.org/show_bug.cgi?id=660795
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Given our needs, GValue is terribly overengineered. We do not need
transformability, and we only have four types of data which won't be
extended. At the same time, GValue is lacking: it can only be copied
around, whereas everything else inside a JsonNode is reference counted.
We can now use the newly introduced JsonValue to replace our usage of
GValue to store values inside a JsonNode, giving us a simpler, reference
counted storage type.
|
|
|
|
|
|
|
|
| |
See GLib bug:
https://bugzilla.gnome.org/show_bug.cgi?id=644611
The macro is going to be deprecated soon.
|
| |
|
|
|
|
| |
https://bugzilla.gnome.org/show_bug.cgi?id=638932
|
| |
|
|
|
|
|
|
|
| |
• Fix the transfer rules for JsonNode, JsonObject and JsonArray
getters.
• Annotate the methods returning lists
|
|
|
|
| |
Useful for debugging and logging purposes.
|
|
|
|
|
| |
Add the setter for JsonNode:parent, to be used in JsonParser instead
of directly accessing the JsonNode structure.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The JSON RFC does not specify the size of the integer type, thus
implicitly falling back to machine-size.
This would all be fine and dandy if some demented Web Developer (and
I use the term "developer" *very much* loosely) did not decide to
use integers to store unique identifiers for objects; obviously, you
can't have more than 2^32-1 status messages in a database with
millions of users who update their status multiple times per day.
Right, Twitter?
Anyway, some languages do a type auto-promotion from Integer to
Long, thus pushing the limit of allowed positive values -- until the
next integer overflow, that is. C, and GLib, do not do that
transparently for us so we need to:
- always use gint64 when parsing a JSON data stream using
JsonScanner
- move all the Node, Object and Array APIs to gint64
- auto-promote G_TYPE_INT to G_TYPE_INT64 when setting
a GValue manually
- auto-promote and auto-demote G_TYPE_INT properties when
(de)serializing GObjects.
The GLib types used internally by JSON-GLib are, thus:
integer -> G_TYPE_INT64
boolean -> G_TYPE_BOOLEAN
float -> G_TYPE_DOUBLE
string -> G_TYPE_STRING
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
| |
The JsonNode structure has always been meant to be completely
opaque; we indirectly exposed the :type member, but only for
access through the JSON_NODE_TYPE() macro.
Since that macro has become a proxy for the json_node_get_node_type()
function we can safely move everything into a private, uninstalled
header file and let JsonNode be completely opaque to the developer.
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Bug 1353 - Copying JSON_NODE_VALUE nodes unreliable at best
When copying a JsonNode to another we do an implicit memcpy using:
*copy = *src
Which works well enough with pointers, but makes a mess out of the
value-based nodes.
We should just copy the type of the original JsonNode and leave the
rest to the switch() block.
In order to catch potential regressions, we also need a more
thorough test unit for the JsonNode copy operation.
|
| |
|
|
|
|
|
| |
If the source JsonNode does not contain data yet, do not try
and copy it.
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
Including the autotools generated config.h should always be conditional
on the HAVE_CONFIG_H definitions.
|
|
|
|
| |
Avoid feeding garbage to the callers by using g_slice_new0().
|
|
|
|
| |
JsonNode payload is inside a union.
|
|
|
|
|
|
| |
We need a GType for nodes if we want to add JsonNode properties or signal
marshallers to a GObject class. We could use pointers, but we'd loose type
safety, so it's a no-no.
|
|
|
|
|
| |
Before calling json_object_unref() or json_array_unref() in json_node_free()
we need to check if the payload of JsonNode is set to avoid a critical.
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
Now that we moved the constructors and setters for the JSON data types into
the public symbols we need to document them to get back to 100% doc coverage.
|
|
|
|
|
|
|
| |
Now that we are providing a generator class we need to provide the
constructors and setters for JsonNode, JsonObject and JsonArray. This
also means that the json-private.h header is now useless, so we can
remove it from the build and repository.
|
|
|
|
|
| |
It seems that the parent accessor fell through. This commit implements
the declared json_node_get_parent() function.
|