Skip to content

porting jsonata-cpp to use QJson instead of nlohmann json library #3

Closed

Description

@u19809

Hi,

I am modify your library to support schema validation with Qt Json backend instead of nlohmann. however that is not the problem.

I develop under windows MSVC2022 and got assert errors when running the tests.

when running jsonata_generated_tests with the nlohmann backend (not the Qt one ) I get test errors :

one I fixed by updating the tokenizer.cpp:379 regex_match (using &*byteEnd is not allowed under msvc)

I also have a test failure with $formatinteger(1e46,'w') which causes integer conversion issues and then std::vector index problems (the converted value is negative).

I also have a test failure :
DEBUG: Using inline data from test definition
--Expr=( $data := { 'number': [1..2e5].$string() }; $values := $data.number; $count($values) ) Expected=200000 ErrorCode=null
--Data=null
--Exception = U1001 --> JSONataException U1001
--ExpectedError = null Expected=200000
WRONG RESULT (exception)
Error in runSubCase(jsonata/test/test-suite/groups/flattening/large.json, 0): Test subcase failed: jsonata/test/test-suite/groups/flattening/large.json_0
C:\Data\Projects\jsonata-cpp\test\gen\flatteningTest.cpp(286): error: Expected: runSubCase("jsonata/test/test-suite/groups/flattening/large.json", 0) doesn't throw an exception.
Actual: it throws std::runtime_error with description "Test subcase failed: jsonata/test/test-suite/groups/flattening/large.json_0".

C:\Data\Projects\jsonata-cpp\test\gen\flatteningTest.cpp(286): error: Expected: runSubCase("jsonata/test/test-suite/groups/flattening/large.json", 0) doesn't throw an exception.
Actual: it throws std::runtime_error with description "Test subcase failed: jsonata/test/test-suite/groups/flattening/large.json_0".

[ FAILED ] flatteningTest.large_case_0 (10040 ms)
[ RUN ] flatteningTest.large_case_1
DEBUG: Using inline data from test definition
--Expr=( $data := { 'number': [1..2e5].$string() }; $values := $lookup($data, 'number'); $count($values) ) Expected=200000 ErrorCode=null
--Data=null
--Exception = U1001 --> JSONataException U1001
--ExpectedError = null Expected=200000
WRONG RESULT (exception)
Error in runSubCase(jsonata/test/test-suite/groups/flattening/large.json, 1): Test subcase failed: jsonata/test/test-suite/groups/flattening/large.json_1
C:\Data\Projects\jsonata-cpp\test\gen\flatteningTest.cpp(291): error: Expected: runSubCase("jsonata/test/test-suite/groups/flattening/large.json", 1) doesn't throw an exception.
Actual: it throws std::runtime_error with description "Test subcase failed: jsonata/test/test-suite/groups/flattening/large.json_1".

[ FAILED ] flatteningTest.large_case_1 (10033 ms)
[ RUN ] flatteningTest.sequence_of_arrays_case_0
C:\Data\Projects\jsonata-cpp\test\gen\flatteningTest.cpp(291): error: Expected: runSubCase("jsonata/test/test-suite/groups/flattening/large.json", 1) doesn't throw an exception.
Actual: it throws std::runtime_error with description "Test subcase failed: jsonata/test/test-suite/groups/flattening/large.json_1".

can you tell me how to treat these test cases ?

Activity

  1. rayokota commented on Jun 15, 2026

    @rayokota
    Owner

    @u19809 , sorry for the delayed response.

    Thanks for the detailed report, two of your issues are now fixed (see #5 and #6), and the third is not a bug, it's a timeout.

    For flattening/large.json U0001, U1001 is the Timebox firing, not an eval error. That test sets a 10,000 ms runtime bound ("timelimit": 10000), and your failures clocked in at 10040 ms and 10033 ms. Generating/flattening 200k elements in a Debug MSVC build (no inlining, _ITERATOR_DEBUG_LEVEL=2, checked STL) is easily 10–50× slower than an optimized build.

    You can either try:

    • Build Release (--config Release) and re-run — these two cases pass on optimized builds.
    • If you need to run Debug, either bump the local timelimit or skip these two perf-sensitive cases for the Debug run.

    Let me know if you have any other issues.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions