| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
| |
Drop `SECTION` blurbs.
Use gi-docgen syntax for internal links.
Use summary lines for gi-docgen indices.
Use Markdown syntax for code fragments.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
| |
This avoids copying the root node for the parse-to-node use-case.
https://bugzilla.gnome.org/show_bug.cgi?id=774688
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
When parsing a JSON object, a member name has to be a valid string, not
an empty one.
|
| |
|
|
|
|
|
| |
JsonParser should be able to use a GInputStream (both synchronously and
asynchronously) to retrieve the JSON data and parse it.
|
| |
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
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 GTokenType extension enumeration belongs with the tokenizer.
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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().
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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 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.
|
| |
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
With this commit, we reach 100% coverage.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
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.
|