Skip to content

Commit

Permalink
Update examples, doc
Browse files Browse the repository at this point in the history
  • Loading branch information
danielaparker committed Jan 26, 2025
1 parent f962ffe commit 4179f2b
Show file tree
Hide file tree
Showing 5 changed files with 7,178 additions and 19 deletions.
15 changes: 10 additions & 5 deletions doc/Examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,16 @@ json_stream_reader reader(is, decoder);
while (!reader.eof())
{
reader.read_next();
if (!reader.eof())
{
json j = decoder.get_result();
std::cout << j << '\n';
}
// until 1.0.0
//if (!reader.eof())
//{
// json j = decoder.get_result();
// std::cout << j << '\n';
//}
// since 1.0.0
json j = decoder.get_result();
std::cout << j << '\n';
}
```
Output:
Expand Down
15 changes: 10 additions & 5 deletions doc/ref/corelib/basic_json_reader.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,16 @@ json_stream_reader reader(is,decoder);
while (!reader.eof())
{
reader.read_next();
if (!reader.eof())
{
json j = decoder.get_result();
std::cout << j << '\n';
}

// until 1.0.0
//if (!reader.eof())
//{
// json j = decoder.get_result();
// std::cout << j << '\n';
//}
// since 1.0.0
json j = decoder.get_result();
std::cout << j << '\n';
}
```
Output:
Expand Down
19 changes: 12 additions & 7 deletions examples/src/json_reader_examples.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,16 @@ void read_mulitple_json_objects()
while (!reader.eof())
{
reader.read_next();
if (!reader.eof())
{
json j = decoder.get_result();
std::cout << j << '\n';
}

// until 1.0.0
//if (!reader.eof())
//{
// json j = decoder.get_result();
// std::cout << j << '\n';
//}
// since 1.0.0
json j = decoder.get_result();
std::cout << j << '\n';
}
}

Expand Down Expand Up @@ -165,7 +170,7 @@ int main()
std::cout << "\njson_reader examples\n\n";

//read_mulitple_json_objects();
read_with_stateful_allocator();
//read_with_stateful_allocator();
//custom_iterator_source();
//read_json_lines();
read_json_lines();
}

Large diffs are not rendered by default.

31 changes: 29 additions & 2 deletions test/fuzz_regression/src/fuzz_regression_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

using namespace jsoncons;

#if 0
TEST_CASE("oss-fuzz issues")
{
#if 0
// Fuzz target: fuzz_parse
// Issue: Stack-overflow
// Diagnosis: During basic_json destruction, an internal compiler stack error occurred in std::vector
Expand Down Expand Up @@ -661,9 +661,33 @@ TEST_CASE("oss-fuzz issues")
}
}
}
}
#endif
// Fuzz target: fuzz_csv_encoder
// Issue: Failed throw
// Resolution:
SECTION("issue 391917540")
{
std::string pathname = "fuzz_regression/input/clusterfuzz-testcase-minimized-fuzz_csv_encoder-4850580052312064";

std::ifstream is(pathname, std::ios_base::in | std::ios_base::binary);
CHECK(is); //-V521

std::string s2;
csv::csv_string_encoder visitor(s2);

csv::csv_stream_reader reader(is, visitor);
std::error_code ec;

REQUIRE_NOTHROW(reader.read(ec));
std::cout << ec.message() << "\n";

//CHECK((ec == csv::csv_errc::source_error)); //-V521

//std::cout << visitor.get_result() << "" << '\n';
}
}

#if 0
TEST_CASE("Fuzz target: fuzz_ubjson_encoder")
{
// Issue: Timeout
Expand Down Expand Up @@ -754,3 +778,6 @@ TEST_CASE("Fuzz target: fuzz_cbor_encoder")
}
}
}
#endif


0 comments on commit 4179f2b

Please sign in to comment.