Skip to content

Commit bd418fe

Browse files
Copilothsluoyz
andcommitted
Address code review: improve numeric type handling in PushObjectJson
Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com>
1 parent 57a0981 commit bd418fe

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

casbin/model/evaluator.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ void ExprtkEvaluator::PushObjectJson(const std::string& target, const std::strin
6969
}
7070
} else if (var.is_string()) {
7171
this->AddIdentifier(identifier, var.get<std::string>());
72-
} else if (var.is_number_integer()) {
73-
this->AddNumericIdentifier(identifier, static_cast<numerical_type>(var.get<int>()));
74-
} else if (var.is_number_float()) {
72+
} else if (var.is_number()) {
73+
// Get as double first to preserve precision, then cast to numerical_type
7574
this->AddNumericIdentifier(identifier, static_cast<numerical_type>(var.get<double>()));
7675
} else if (var.is_boolean()) {
7776
this->AddNumericIdentifier(identifier, static_cast<numerical_type>(var.get<bool>() ? 1 : 0));

0 commit comments

Comments
 (0)