Skip to content

JSON writer emits invalid output for nested lists #2068

@Neverlord

Description

@Neverlord

Reported offline. Here's a test that reproduces the error:

SCENARIO("the JSON writer can render nested lists") {
  GIVEN("a list of lists") {
    std::vector<std::vector<int>> x{{1, 2}, {3, 4}};
    WHEN("converting it to JSON with indentation factor 0") {
      THEN("the JSON output is a single line") {
        check_eq(to_json_string(x, 0), "[[1, 2], [3, 4]]"s);
      }
    }
    WHEN("converting it to JSON with indentation factor 2") {
      THEN("the JSON output uses multiple lines") {
        std::string out = R"_([
  [1, 2],
  [3, 4]
])_";
        check_eq(to_json_string(x, 2), out);
      }
    }
  }
}

Correct output: [[1, 2], [3, 4]]. CAF output: [[1, 2][3, 4]].

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No fields configured for Bug.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions