| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
| |
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.
|