After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 741824 - reader: Maintain a stack of member names
reader: Maintain a stack of member names
Status: RESOLVED FIXED
Product: json-glib
Classification: Core
Component: Parser
git master
Other Linux
: Normal normal
: ---
Assigned To: json-glib-maint
json-glib-maint
Depends on:
Blocks:
 
 
Reported: 2014-12-20 23:26 UTC by Philip Withnall
Modified: 2015-01-25 17:02 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
reader: Maintain a stack of member names (5.59 KB, patch)
2014-12-20 23:27 UTC, Philip Withnall
committed Details | Review

Description Philip Withnall 2014-12-20 23:26:58 UTC
Patch coming to fix json_reader_get_member_name() when using nested objects.
Comment 1 Philip Withnall 2014-12-20 23:27:22 UTC
Created attachment 293136 [details] [review]
reader: Maintain a stack of member names

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.
Comment 2 Emmanuele Bassi (:ebassi) 2015-01-25 15:56:27 UTC
Review of attachment 293136 [details] [review]:

LGTM.
Comment 3 Philip Withnall 2015-01-25 17:02:45 UTC
Attachment 293136 [details] pushed as 1f6668a - reader: Maintain a stack of member names