summaryrefslogtreecommitdiff
path: root/json-glib/json-reader.c
Commit message (Collapse)AuthorAgeFilesLines
* Add new api json_reader_get_current_nodeFrederic Martinsons2022-10-111-0/+19
| | | | | | | | | | | This can be useful to extract a sub json structure during parsing of another (for example when we don't know in advance the format of this sub json and just want to pass it to another consumer). Closes #9 Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
* Update the JsonReader documentationEmmanuele Bassi2021-06-101-99/+152
|
* docs: Initial, rough port away from gtk-docEmmanuele Bassi2021-06-081-51/+50
| | | | | | | | | | Drop `SECTION` blurbs. Use gi-docgen syntax for internal links. Use summary lines for gi-docgen indices. Use Markdown syntax for code fragments.
* core: Avoid json_object_get_members()Garrett Regier2017-06-161-13/+10
| | | | | | | Use JsonObject's private members_ordered GQueue instead. This avoids a g_list_copy(). https://bugzilla.gnome.org/show_bug.cgi?id=773504
* introspection: fix nullable annotation for return values in the following ↵Alberto Ruiz2017-03-181-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | methods json_builder_add_boolean_value json_builder_add_double_value json_builder_add_int_value json_builder_add_null_value json_builder_add_string_value json_builder_add_value json_builder_begin_array json_builder_begin_object json_builder_end_array json_builder_end_object json_builder_get_root json_builder_set_member_name json_generator_get_root json_reader_get_error json_reader_get_member_name json_reader_get_value json_serializable_find_property json_serializable_find_property json_boxed_serialize
* reader: Make json_reader_get_value return a value for the null type. This ↵Robert Ancell2017-03-181-1/+1
| | | | | | matches the json_reader_is_value check. https://bugzilla.gnome.org/show_bug.cgi?id=758580
* Use Unicode in translatable stringsPiotr Drąg2017-03-181-13/+13
| | | | | | See https://developer.gnome.org/hig/stable/typography.html https://bugzilla.gnome.org/show_bug.cgi?id=772753
* Annotate internal set_error() wrapperEmmanuele Bassi2017-03-131-0/+1
| | | | | | | We need to tell the compiler that the 3rd argument is a format-like string, and that the arguments for that come in the variadic arguments list; this allows compilers like GCC to do validation on the format string itself, and avoid a whole class of bugs.
* node: Add json_node_ref() and json_node_unref()Philip Withnall2016-03-011-2/+2
| | | | | | | | | | | | | | 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
* Fix code returning FALSE when it should be NULLRobert Ancell2015-11-241-1/+1
|
* reader: Clarify use of json_reader_end_[element|member]() with errorsPhilip Withnall2015-08-181-2/+29
| | | | | | | | Include an example showing that the end function must be called on both code paths (success and failure) if the reader object is to be used afterwards. https://bugzilla.gnome.org/show_bug.cgi?id=744100
* reader: Maintain a stack of member namesPhilip Withnall2015-01-251-13/+16
| | | | | | | | | | | | | | | | | | | | | This fixes the case where, with nested objects, we call: json_reader_read_member (reader, "outer"); // json_reader_get_member_name (reader) == "outer" json_reader_read_member (reader, "inner"); // json_reader_get_member_name (reader) == "inner" // do something useful json_reader_end_member (reader); but at the end, the following assertion no longer holds: // json_reader_get_member_name (reader) == "outer" even though the JsonReader state should have been reset after ending the inner node. Fix it by maintaining a stack of member names. This works with both json_reader_read_member() and json_reader_read_element(). Updates to the unit tests are included. https://bugzilla.gnome.org/show_bug.cgi?id=741824
* Remove conditional inclusion of config.hEmmanuele Bassi2014-03-181-4/+0
| | | | All the platforms and build system we support have a config.h header.
* docs: Port to MarkDownEmmanuele Bassi2014-03-181-11/+8
| | | | | Drop the DocBook documentation, and move everything to the MarkDown format used by modern gtk-doc.
* reader: When a read() fails, don't track back on end()Bastien Nocera2014-02-031-4/+12
| | | | | | | | | | | | | | When a call to json_reader_read_element() fails if the element doesn't exist, we need to call json_reader_end_element() to clear out any errors. But the _end_element() call will backtrack to the parent node, when the _read_element() call did not set the child node. To fix this, leave early from _end_*() calls when an error has been set. https://bugzilla.gnome.org/show_bug.cgi?id=723428
* reader: Fix example code for json_reader_read_member()Bastien Nocera2014-02-031-3/+3
| | | | | | Fix cut'n'paste error. https://bugzilla.gnome.org/show_bug.cgi?id=721137
* Remove compile time GLib version checkEmmanuele Bassi2013-08-211-13/+0
| | | | | We depend on a new version of GLib, so we can remove a bunch of old version checks.
* Use new macros when compiling against new GLibEmmanuele Bassi2013-07-201-0/+10
| | | | | | | | If we're being compiled against a newer version of GLib, we should use the new macros that add instance private data. Since this is a stable branch, we cannot bump the GLib requirement; so we use version checks to conditionally compile the new code.
* Use G_DEFINE_QUARK macroEmmanuele Bassi2013-05-161-7/+3
| | | | Instead of hand-writing the error domain function ourselves.
* reader: "null" is a valueEmmanuele Bassi2012-10-271-1/+2
| | | | | Even if we have a special JsonNode for it. The json_reader_is_value() function should return TRUE for 'null' nodes as well.
* reader: Do not do strict type validation on numeric typesEmmanuele Bassi2012-07-151-21/+0
| | | | JsonNode will do an implicit conversion for us.
* reader: Do more strict validationEmmanuele Bassi2011-09-091-23/+154
| | | | | | | | JsonReader should perform more strict validation, and put itself in an error state whenever the user asks for values or information on nodes that are not there, or not of the right type. https://bugzilla.gnome.org/show_bug.cgi?id=658632
* Remove G_CONST_RETURN usageEmmanuele Bassi2011-06-091-3/+3
| | | | | | | | See GLib bug: https://bugzilla.gnome.org/show_bug.cgi?id=644611 The macro is going to be deprecated soon.
* Mark GError messages for translationsEmmanuele Bassi2011-06-011-10/+10
| | | | These errors might find their way into a UI.
* Add i18n machineryEmmanuele Bassi2011-06-011-0/+2
| | | | We need to translate the GError messages.
* reader: Fix bug in example usageBastien Nocera2011-04-211-1/+1
|
* reader: Plug a leakEmmanuele Bassi2011-02-061-9/+6
| | | | | | Free the current_member string, and since we're destroying data we own let's do it inside the finalize implementation instead of the dispose one.
* reader: Add accessor for the member nameEmmanuele Bassi2011-02-061-0/+32
| | | | This should allow easy access to the member name during iteration.
* reader: Allow using read_element() on objectsEmmanuele Bassi2011-02-061-16/+51
| | | | | | | | | | | | | | | If we assume that a JSON object is just an array with a named mapping then the JsonReader API should be able to descend into objects using the same API used for arrays. This obviously is less useful than it sounds if we take a very strict interpretation of JSON objects as unordered string-to-value mappings; as the ordering is not guaranteed to be stable, parsers would be fairly weak against various JSON definitions. If the JSON format parsed is guaranteed to be stable then an integer offset might be an easy (albeit slightly less performant) way to access data.
* reader: Add list_members() methodEmmanuele Bassi2011-02-041-0/+46
| | | | | 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.
* reader: Use GObject ≥ 2.26 APIEmmanuele Bassi2010-12-141-20/+15
| | | | Use modern API to deal with properties installation and notification.
* reader: Add :root constructor propertyEmmanuele Bassi2010-08-141-8/+88
| | | | | A JsonReader is useless without a root JsonNode to start walking the tree from.
* reader: Do not wrap JsonParserEmmanuele Bassi2010-08-121-61/+29
| | | | | | | 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.
* reader: Mirror the JsonBuilder API value accessorsEmmanuele Bassi2010-08-121-17/+17
| | | | We should strive to make JsonBuilder and JsonReader similar in API.
* Add JsonReaderEmmanuele Bassi2010-08-121-0/+779
JsonReader is a simple, cursor-based API for parsing a JSON DOM. It is similar, in spirit, to the XmlReader API provided by various platforms and XML parsing libraries.