|
|
|
@ -40,6 +40,7 @@ bool ParseDurationFromJson(const Json& field, grpc_millis* duration); |
|
|
|
|
// Return true on success, false otherwise. If an error is encountered during
|
|
|
|
|
// parsing, a descriptive error is appended to \a error_list.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
template <typename NumericType> |
|
|
|
|
bool ExtractJsonNumber(const Json& json, absl::string_view field_name, |
|
|
|
|
NumericType* output, |
|
|
|
@ -84,39 +85,32 @@ bool ExtractJsonObject(const Json& json, absl::string_view field_name, |
|
|
|
|
const Json::Object** output, |
|
|
|
|
std::vector<grpc_error_handle>* error_list); |
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Wrappers for automatically choosing one of the above functions based
|
|
|
|
|
// on output parameter type.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
template <typename NumericType> |
|
|
|
|
inline bool ExtractJsonType(const Json& json, absl::string_view field_name, |
|
|
|
|
bool ExtractJsonType(const Json& json, absl::string_view field_name, |
|
|
|
|
NumericType* output, |
|
|
|
|
std::vector<grpc_error_handle>* error_list) { |
|
|
|
|
return ExtractJsonNumber(json, field_name, output, error_list); |
|
|
|
|
} |
|
|
|
|
inline bool ExtractJsonType(const Json& json, absl::string_view field_name, |
|
|
|
|
bool ExtractJsonType(const Json& json, absl::string_view field_name, |
|
|
|
|
bool* output, |
|
|
|
|
std::vector<grpc_error_handle>* error_list) { |
|
|
|
|
return ExtractJsonBool(json, field_name, output, error_list); |
|
|
|
|
} |
|
|
|
|
inline bool ExtractJsonType(const Json& json, absl::string_view field_name, |
|
|
|
|
std::vector<grpc_error_handle>* error_list); |
|
|
|
|
bool ExtractJsonType(const Json& json, absl::string_view field_name, |
|
|
|
|
std::string* output, |
|
|
|
|
std::vector<grpc_error_handle>* error_list) { |
|
|
|
|
return ExtractJsonString(json, field_name, output, error_list); |
|
|
|
|
} |
|
|
|
|
inline bool ExtractJsonType(const Json& json, absl::string_view field_name, |
|
|
|
|
std::vector<grpc_error_handle>* error_list); |
|
|
|
|
bool ExtractJsonType(const Json& json, absl::string_view field_name, |
|
|
|
|
absl::string_view* output, |
|
|
|
|
std::vector<grpc_error_handle>* error_list) { |
|
|
|
|
return ExtractJsonString(json, field_name, output, error_list); |
|
|
|
|
} |
|
|
|
|
inline bool ExtractJsonType(const Json& json, absl::string_view field_name, |
|
|
|
|
std::vector<grpc_error_handle>* error_list); |
|
|
|
|
bool ExtractJsonType(const Json& json, absl::string_view field_name, |
|
|
|
|
const Json::Array** output, |
|
|
|
|
std::vector<grpc_error_handle>* error_list) { |
|
|
|
|
return ExtractJsonArray(json, field_name, output, error_list); |
|
|
|
|
} |
|
|
|
|
inline bool ExtractJsonType(const Json& json, absl::string_view field_name, |
|
|
|
|
std::vector<grpc_error_handle>* error_list); |
|
|
|
|
bool ExtractJsonType(const Json& json, absl::string_view field_name, |
|
|
|
|
const Json::Object** output, |
|
|
|
|
std::vector<grpc_error_handle>* error_list) { |
|
|
|
|
return ExtractJsonObject(json, field_name, output, error_list); |
|
|
|
|
} |
|
|
|
|
std::vector<grpc_error_handle>* error_list); |
|
|
|
|
|
|
|
|
|
// Extracts a field from a JSON object, automatically selecting the type
|
|
|
|
|
// of parsing based on the output parameter type.
|
|
|
|
|