Skip to content

Conversation

@freitass
Copy link

@freitass freitass commented Dec 4, 2025

Fixes a corner case where, when parsing unexpected arrays in nested JSON objects, the ignoring_handler would incorrectly signal signal_end instead of signal_value, causing the parser to skip the rest of the containing object.

struct X
{
    int a;
    float b;
    std::string c;
};

BOOST_DESCRIBE_STRUCT(X, (), (a, b, c))

struct W
{
    X x;
};

BOOST_DESCRIBE_STRUCT(W, (), (x))

// ...

const auto json = R"(
{
    "x": {
        "unexpected": [],
        "a": 1,
        "b": 3.14,
        "c": "hello"
    }
})";

W w{};
std::error_code ec;
parse_into(w, json, ec);

BOOST_TEST( !ec );               // Ok.
BOOST_TEST( w.x.a == 1 );        // Error: w.x.a is 0
BOOST_TEST( w.x.b == 3.14f );    // Error: w.x.b is 0.0
BOOST_TEST( w.x.c == "hello" );  // Error: w.x.c is ""

@cppalliance-bot
Copy link

cppalliance-bot commented Dec 4, 2025

An automated preview of the documentation is available at https://1129.json.prtest2.cppalliance.org/libs/json/doc/html/index.html

If more commits are pushed to the pull request, the docs will rebuild at the same URL.

2025-12-05 14:22:00 UTC

@cppalliance-bot
Copy link

@grisumbras
Copy link
Member

First, thank you for catching and fixing this.

Please, rebase on develop so that CI jobs succeed.

When parsing unexpected fields containing arrays in described structs,
signal_value instead of signal_end to avoid prematurely exiting the
parent object context.
@codecov
Copy link

codecov bot commented Dec 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.67%. Comparing base (91b6516) to head (707a450).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1129      +/-   ##
===========================================
- Coverage    93.71%   93.67%   -0.05%     
===========================================
  Files           91       91              
  Lines         9153     9153              
===========================================
- Hits          8578     8574       -4     
- Misses         575      579       +4     
Files with missing lines Coverage Δ
include/boost/json/detail/parse_into.hpp 99.33% <100.00%> (-0.67%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 91b6516...707a450. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cppalliance-bot
Copy link

@freitass
Copy link
Author

freitass commented Dec 5, 2025

Branch updated, not sure why the coverage dropped -0.05%.

@grisumbras
Copy link
Member

Seems like it's a coverage service bug. I'm discussing dropping that. Bad coverage reports are worse than no coverage reports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants