You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, when json element is empty and we're trying to iterate it application throws the error.
I believe that in this situations loop should be skipped but not stopped.
Fix is pretty easy, it's necessary to test for null in eval_expression function
template<typename T = json>
T eval_expression(const Parsed::ElementExpression& element, const json& data) {
const json var = eval_function(element, data);
if (var.is_null()) // << test if element is empty
return T(); // << return empty
try {
return var.get<T>();
} catch (json::type_error& e) {
inja_throw("json_error", e.what());
throw;
}
}
The use case is that I'm filling database data to the json context and generating some stats from such data. But when array of data is empty the generator throw error instead of generating empty data.
The text was updated successfully, but these errors were encountered:
Currently, when json element is empty and we're trying to iterate it application throws the error.
I believe that in this situations loop should be skipped but not stopped.
Fix is pretty easy, it's necessary to test for null in
eval_expression
functionThe use case is that I'm filling database data to the json context and generating some stats from such data. But when array of data is empty the generator throw error instead of generating empty data.
The text was updated successfully, but these errors were encountered: