void constant_value_to_json()

in serving/reagent/serving/core/Containers.cpp [45:80]


void constant_value_to_json(const ConstantValue& value, json& j) {
  j = std::visit(
      [j](auto&& arg) -> json {
        using T = std::decay_t<decltype(arg)>;
        json j;
        if (std::is_same_v<T, std::string>) {
          j["string_value"] = arg;
        } else if (std::is_same_v<T, int64_t>) {
          j["int_value"] = arg;
        } else if (std::is_same_v<T, double>) {
          j["double_value"] = arg;
        } else if (std::is_same_v<T, StringList>) {
          j["list_string_value"] = arg;
        } else if (std::is_same_v<T, std::vector<int64_t>>) {
          j["list_int_value"] = arg;
        } else if (std::is_same_v<T, std::vector<double>>) {
          j["list_double_value"] = arg;
        } else if (std::is_same_v<T, StringStringMap>) {
          j["map_string_value"] = arg;
        } else if (std::is_same_v<T, StringIntMap>) {
          j["map_int_value"] = arg;
        } else if (std::is_same_v<T, StringDoubleMap>) {
          j["map_double_value"] = arg;
        } else if (std::is_same_v<T, RankedActionList>) {
          j["ranked_action_list"] = arg;
        } else if (std::is_same_v<
                       T, std::unordered_map<std::string, StringDoubleMap>>) {
          j["map_map_double_value"] = arg;
        } else {
          LOG(FATAL) << "INVALID OUTPUT OPERATOR";
          LOG_AND_THROW("Invalid output operator");
        }
        return j;
      },
      value);
}