diff --git a/lix/libutil/deprecated-features-json.hh b/lix/libutil/deprecated-features-json.hh index f3992e64b..913c437cd 100644 --- a/lix/libutil/deprecated-features-json.hh +++ b/lix/libutil/deprecated-features-json.hh @@ -20,10 +20,4 @@ JSON documentDeprecatedFeatures(); void to_json(JSON &, const DeprecatedFeature &); void from_json(const JSON &, DeprecatedFeature &); -/** - * It is always rendered as a string - */ -template<> -struct json_avoids_null : std::true_type {}; - }; diff --git a/lix/libutil/experimental-features-json.hh b/lix/libutil/experimental-features-json.hh index 8a31d4548..8329c7e41 100644 --- a/lix/libutil/experimental-features-json.hh +++ b/lix/libutil/experimental-features-json.hh @@ -20,10 +20,4 @@ JSON documentExperimentalFeatures(); void to_json(JSON &, const ExperimentalFeature &); void from_json(const JSON &, ExperimentalFeature &); -/** - * It is always rendered as a string - */ -template<> -struct json_avoids_null : std::true_type {}; - }; diff --git a/lix/libutil/json-utils.hh b/lix/libutil/json-utils.hh index bae902892..7f75f1baa 100644 --- a/lix/libutil/json-utils.hh +++ b/lix/libutil/json-utils.hh @@ -3,6 +3,7 @@ #include "lix/libutil/json.hh" #include +#include namespace nix { @@ -41,10 +42,12 @@ template struct json_avoids_null; /** - * Handle numbers in default impl + * Handle numbers and enums in default impl */ template -struct json_avoids_null : std::bool_constant::value> {}; +struct json_avoids_null + : std::bool_constant || std::is_floating_point_v || std::is_enum_v> +{}; template<> struct json_avoids_null : std::false_type {};