Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
trivialfis committed Jun 11, 2021
1 parent 46afb0d commit 993141e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/tree/tree_model.cc
Expand Up @@ -402,7 +402,7 @@ class JsonGenerator : public TreeGenerator {
auto cats = GetSplitCategory(tree, nid);
static std::string const kCategoryTemplate =
R"I( "nodeid": {nid}, "depth": {depth}, "split": "{fname}", )I"
R"I("split_condition": {cond}, "yes", {right}, "no", {left}, )I"
R"I("split_condition": {cond}, "yes": {right}, "no": {left}, )I"
R"I("missing", {missing})I";
std::string cats_ptr = "[";
for (size_t i = 0; i < cats.size(); ++i) {
Expand Down
5 changes: 5 additions & 0 deletions tests/cpp/tree/test_tree_model.cc
Expand Up @@ -294,6 +294,11 @@ void TestCategoricalTreeDump(std::string format, std::string sep) {
ASSERT_NE(pos, std::string::npos);
pos = str.find(cond_str, pos + 1);
ASSERT_NE(pos, std::string::npos);

if (format == "json") {
// Make sure it's valid JSON
Json::Load(StringView{str});
}
}
} // anonymous namespace

Expand Down

0 comments on commit 993141e

Please sign in to comment.