}
}
+// treat a null value as absent so clients can send null to request the server default
+static bool has_value(const json & data, const char * n) {
+ auto it = data.find(n);
+ return it != data.end() && !it->is_null();
+}
+
template <typename T>
void field_num<T>::eval(field_eval_context & ctx, const json & data) {
for (const auto & n : name) {
- if (data.contains(n)) {
+ if (has_value(data, n)) {
handle_with_catch(n, [&]() {
if (custom_handler) {
custom_handler(ctx, data);
void field_str::eval(field_eval_context & ctx, const json & data) {
GGML_ASSERT(custom_handler);
for (const auto & n : name) {
- if (data.contains(n)) {
+ if (has_value(data, n)) {
handle_with_catch(n, [&]() {
custom_handler(ctx, data);
});
void field_bool::eval(field_eval_context & ctx, const json & data) {
for (const auto & n : name) {
- if (data.contains(n)) {
+ if (has_value(data, n)) {
handle_with_catch(n, [&]() {
if (custom_handler) {
custom_handler(ctx, data);
void field_json::eval(field_eval_context & ctx, const json & data) {
GGML_ASSERT(custom_handler);
for (const auto & n : name) {
- if (data.contains(n)) {
+ if (has_value(data, n)) {
handle_with_catch(n, [&]() {
custom_handler(ctx, data);
});