Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug processing "jsonlines". #586

Open
wiluite opened this issue Jan 25, 2025 · 2 comments
Open

Bug processing "jsonlines". #586

wiluite opened this issue Jan 25, 2025 · 2 comments
Labels

Comments

@wiluite
Copy link

wiluite commented Jan 25, 2025

Describe the bug

Sooner, in version 0.177 (or so), I'd uncommented lines:
read_mulitple_json_objects();
read_json_lines();

in json_reader_examples.cpp source.

And these ndjson (so called "jsonlines") examples worked as expected.

However, right now, they don't process exactly one line - the last one.
Is it possible to fix this? (I'm guessing they are commented out and not necessarily working, but they did work before.)

expected behavior: Output to a stream the last line also proccessed.
actual behavior: It does not output the last line as processed.

Enumerate the steps to reproduce the bug

  • uncomment read_mulitple_json_objects() in json_reader_examples.cpp sample, build, run.

What compiler, architecture, and operating system?

  • Compiler: MinGW
  • Architecture (e.g. x86, x64) x64
  • Operating system: Windows 11

What jsoncons library version?

  • [ x] master
@wiluite wiluite added the Bug label Jan 25, 2025
@danielaparker
Copy link
Owner

danielaparker commented Jan 26, 2025

Thanks for reporting that. The behavior of the basic_json_parser::eof() function changed in 1.0.0, that change should have been reflected in the CHANGELOG and examples, but was overlooked. Until 1.0.0, the example had to be written as

while (!reader.eof())   
{
    reader.read_next();
    if (!reader.eof())
    {
        json j = decoder.get_result();
        std::cout << j << '\n';
    }
}

Since 1.0.0, it needs to be written as

while (!reader.eof())   
{
    reader.read_next();  
    json j = decoder.get_result();
    std::cout << j << '\n';
}

@wiluite
Copy link
Author

wiluite commented Jan 26, 2025

Oh, I could have guessed to write the cycle differently because the previous variant looks a little stange. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants