From 1432fe4e4c46c6c9eac0d0f250dc7022c99f82e8 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Tue, 9 May 2023 08:05:24 -0700 Subject: [PATCH] [JSON] make API public but experimental (#32987) This makes the JSON API visible as part of the C-core API, but in the `experimental` namespace. It will be used as part of various experimental APIs that we will be introducing in the near future, such as the audit logging API. --- .gitattributes | 3 + BUILD | 6 +- CMakeLists.txt | 4 + Makefile | 3 + build_autogenerated.yaml | 4 + gRPC-Core.podspec | 1 + grpc.gemspec | 1 + include/grpc/grpc_audit_logging.h | 5 +- include/grpc/module.modulemap | 1 + include/grpc/support/json.h | 218 ++++++++++++++++++ package.xml | 1 + src/core/BUILD | 5 - .../filters/client_channel/client_channel.cc | 1 + .../client_channel/client_channel_channelz.cc | 2 + .../client_channel/lb_policy/grpclb/grpclb.cc | 1 + .../client_channel/lb_policy/rls/rls.cc | 1 + .../client_channel/lb_policy/xds/cds.cc | 1 + .../lb_policy/xds/xds_cluster_resolver.cc | 1 + .../lb_policy/xds/xds_wrr_locality.cc | 1 + .../google_c2p/google_c2p_resolver.cc | 1 + .../client_channel/retry_service_config.cc | 1 + .../ext/xds/certificate_provider_store.cc | 1 + src/core/ext/xds/xds_audit_logger_registry.cc | 2 + src/core/ext/xds/xds_bootstrap_grpc.cc | 2 + src/core/ext/xds/xds_cluster.cc | 1 + .../ext/xds/xds_cluster_specifier_plugin.cc | 1 + src/core/ext/xds/xds_common_types.cc | 2 + src/core/ext/xds/xds_http_fault_filter.cc | 1 + src/core/ext/xds/xds_http_rbac_filter.cc | 2 + .../xds/xds_http_stateful_session_filter.cc | 2 + src/core/ext/xds/xds_lb_policy_registry.cc | 2 + src/core/lib/channel/channel_trace.cc | 1 + src/core/lib/channel/channelz.cc | 1 + src/core/lib/channel/channelz_registry.cc | 9 +- src/core/lib/json/json.h | 190 +-------------- src/core/lib/json/json_reader.cc | 1 + .../lib/load_balancing/lb_policy_registry.cc | 1 + .../security/authorization/audit_logging.cc | 1 - .../security/authorization/audit_logging.h | 2 +- .../security/authorization/rbac_translator.cc | 1 + .../aws_external_account_credentials.cc | 1 + .../external/external_account_credentials.cc | 1 + .../file_external_account_credentials.cc | 1 + .../url_external_account_credentials.cc | 1 + .../google_default_credentials.cc | 1 + .../security/credentials/jwt/json_token.cc | 6 +- .../credentials/jwt/jwt_credentials.cc | 1 + .../security/credentials/jwt/jwt_verifier.cc | 1 + .../credentials/oauth2/oauth2_credentials.cc | 1 + src/core/lib/security/util/json_util.cc | 1 + src/cpp/client/secure_credentials.cc | 1 + test/core/channel/channelz_test.cc | 1 + .../lb_policy/outlier_detection_test.cc | 1 + .../lb_policy/weighted_round_robin_test.cc | 1 + .../lb_policy/xds_override_host_test.cc | 1 + test/core/json/fuzzer.cc | 3 +- test/core/json/json_object_loader_test.cc | 2 + test/core/json/json_test.cc | 4 + test/core/security/verify_jwt.cc | 2 +- test/core/xds/xds_bootstrap_test.cc | 1 + test/core/xds/xds_client_test.cc | 1 + test/core/xds/xds_http_filters_test.cc | 1 + test/cpp/util/channel_trace_proto_helper.cc | 2 +- test/cpp/util/channelz_sampler.cc | 4 +- tools/distrib/check_include_guards.py | 6 +- tools/doxygen/Doxyfile.c++ | 1 + tools/doxygen/Doxyfile.c++.internal | 1 + tools/doxygen/Doxyfile.core | 1 + tools/doxygen/Doxyfile.core.internal | 1 + 69 files changed, 324 insertions(+), 211 deletions(-) create mode 100644 include/grpc/support/json.h diff --git a/.gitattributes b/.gitattributes index 49c95a2ce25..320a1f8e618 100644 --- a/.gitattributes +++ b/.gitattributes @@ -19,8 +19,11 @@ binding.gyp linguist-generated=true src/python/grpcio/grpc_core_dependencies.py linguist-generated=true src/ruby/ext/grpc/rb_grpc_imports.generated.h linguist-generated=true src/ruby/ext/grpc/rb_grpc_imports.generated.c linguist-generated=true +include/grpc/module.modulemap linguist-generated=true test/core/security/grpc_tls_credentials_options_comparator_test.cc linguist-generated=true +tools/doxygen/Doxyfile.c++ linguist-generated=true tools/doxygen/Doxyfile.c++.internal linguist-generated=true +tools/doxygen/Doxyfile.core linguist-generated=true tools/doxygen/Doxyfile.core.internal linguist-generated=true tools/run_tests/sources_and_headers.json linguist-generated=true tools/run_tests/tests.json linguist-generated=true diff --git a/BUILD b/BUILD index b0b29f7e9b7..48ac13c6329 100644 --- a/BUILD +++ b/BUILD @@ -203,6 +203,7 @@ GPR_PUBLIC_HDRS = [ "include/grpc/support/atm_gcc_sync.h", "include/grpc/support/atm_windows.h", "include/grpc/support/cpu.h", + "include/grpc/support/json.h", "include/grpc/support/log.h", "include/grpc/support/log_windows.h", "include/grpc/support/port_platform.h", @@ -745,6 +746,10 @@ grpc_cc_library( grpc_cc_library( name = "gpr_public_hdrs", hdrs = GPR_PUBLIC_HDRS, + external_deps = [ + "absl/strings", + "absl/types:variant", + ], tags = [ "avoid_dep", "nofixdeps", @@ -1769,7 +1774,6 @@ grpc_cc_library( "//src/core:handshaker_factory", "//src/core:handshaker_registry", "//src/core:iomgr_fwd", - "//src/core:json", "//src/core:memory_quota", "//src/core:poll", "//src/core:ref_counted", diff --git a/CMakeLists.txt b/CMakeLists.txt index 7506eb9b469..f23c31413cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1544,6 +1544,7 @@ foreach(_hdr include/grpc/support/atm_gcc_sync.h include/grpc/support/atm_windows.h include/grpc/support/cpu.h + include/grpc/support/json.h include/grpc/support/log.h include/grpc/support/log_windows.h include/grpc/support/port_platform.h @@ -2452,6 +2453,7 @@ foreach(_hdr include/grpc/support/atm_gcc_sync.h include/grpc/support/atm_windows.h include/grpc/support/cpu.h + include/grpc/support/json.h include/grpc/support/log.h include/grpc/support/log_windows.h include/grpc/support/port_platform.h @@ -3090,6 +3092,7 @@ foreach(_hdr include/grpc/support/atm_gcc_sync.h include/grpc/support/atm_windows.h include/grpc/support/cpu.h + include/grpc/support/json.h include/grpc/support/log.h include/grpc/support/log_windows.h include/grpc/support/port_platform.h @@ -4600,6 +4603,7 @@ foreach(_hdr include/grpc/support/atm_gcc_sync.h include/grpc/support/atm_windows.h include/grpc/support/cpu.h + include/grpc/support/json.h include/grpc/support/log.h include/grpc/support/log_windows.h include/grpc/support/port_platform.h diff --git a/Makefile b/Makefile index 198812fcd87..ccf783558b7 100644 --- a/Makefile +++ b/Makefile @@ -908,6 +908,7 @@ PUBLIC_HEADERS_C += \ include/grpc/support/atm_gcc_sync.h \ include/grpc/support/atm_windows.h \ include/grpc/support/cpu.h \ + include/grpc/support/json.h \ include/grpc/support/log.h \ include/grpc/support/log_windows.h \ include/grpc/support/port_platform.h \ @@ -1777,6 +1778,7 @@ PUBLIC_HEADERS_C += \ include/grpc/support/atm_gcc_sync.h \ include/grpc/support/atm_windows.h \ include/grpc/support/cpu.h \ + include/grpc/support/json.h \ include/grpc/support/log.h \ include/grpc/support/log_windows.h \ include/grpc/support/port_platform.h \ @@ -2270,6 +2272,7 @@ PUBLIC_HEADERS_C += \ include/grpc/support/atm_gcc_sync.h \ include/grpc/support/atm_windows.h \ include/grpc/support/cpu.h \ + include/grpc/support/json.h \ include/grpc/support/log.h \ include/grpc/support/log_windows.h \ include/grpc/support/port_platform.h \ diff --git a/build_autogenerated.yaml b/build_autogenerated.yaml index 9ef8a34d441..e6b4e404922 100644 --- a/build_autogenerated.yaml +++ b/build_autogenerated.yaml @@ -36,6 +36,7 @@ libs: - include/grpc/support/atm_gcc_sync.h - include/grpc/support/atm_windows.h - include/grpc/support/cpu.h + - include/grpc/support/json.h - include/grpc/support/log.h - include/grpc/support/log_windows.h - include/grpc/support/port_platform.h @@ -195,6 +196,7 @@ libs: - include/grpc/support/atm_gcc_sync.h - include/grpc/support/atm_windows.h - include/grpc/support/cpu.h + - include/grpc/support/json.h - include/grpc/support/log.h - include/grpc/support/log_windows.h - include/grpc/support/port_platform.h @@ -1897,6 +1899,7 @@ libs: - include/grpc/support/atm_gcc_sync.h - include/grpc/support/atm_windows.h - include/grpc/support/cpu.h + - include/grpc/support/json.h - include/grpc/support/log.h - include/grpc/support/log_windows.h - include/grpc/support/port_platform.h @@ -3484,6 +3487,7 @@ libs: - include/grpc/support/atm_gcc_sync.h - include/grpc/support/atm_windows.h - include/grpc/support/cpu.h + - include/grpc/support/json.h - include/grpc/support/log.h - include/grpc/support/log_windows.h - include/grpc/support/port_platform.h diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index b65ee6d58c7..c83c21b0884 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -163,6 +163,7 @@ Pod::Spec.new do |s| 'include/grpc/support/atm_gcc_sync.h', 'include/grpc/support/atm_windows.h', 'include/grpc/support/cpu.h', + 'include/grpc/support/json.h', 'include/grpc/support/log.h', 'include/grpc/support/log_windows.h', 'include/grpc/support/port_platform.h', diff --git a/grpc.gemspec b/grpc.gemspec index f2208cabb87..c2a633d5d56 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -103,6 +103,7 @@ Gem::Specification.new do |s| s.files += %w( include/grpc/support/atm_gcc_sync.h ) s.files += %w( include/grpc/support/atm_windows.h ) s.files += %w( include/grpc/support/cpu.h ) + s.files += %w( include/grpc/support/json.h ) s.files += %w( include/grpc/support/log.h ) s.files += %w( include/grpc/support/log_windows.h ) s.files += %w( include/grpc/support/port_platform.h ) diff --git a/include/grpc/grpc_audit_logging.h b/include/grpc/grpc_audit_logging.h index a74ba8fd775..a63d324710c 100644 --- a/include/grpc/grpc_audit_logging.h +++ b/include/grpc/grpc_audit_logging.h @@ -27,8 +27,7 @@ #include "absl/status/statusor.h" #include "absl/strings/string_view.h" -// TODO(lwge): Switch to public header when it's ready. -#include "src/core/lib/json/json.h" +#include namespace grpc_core { namespace experimental { @@ -93,4 +92,4 @@ void RegisterAuditLoggerFactory(std::unique_ptr factory); } // namespace experimental } // namespace grpc_core -#endif /* GRPC_GRPC_AUDIT_LOGGING_H */ +#endif // GRPC_GRPC_AUDIT_LOGGING_H diff --git a/include/grpc/module.modulemap b/include/grpc/module.modulemap index 49c3c3dfddf..3f8840ccaff 100644 --- a/include/grpc/module.modulemap +++ b/include/grpc/module.modulemap @@ -40,6 +40,7 @@ header "byte_buffer.h" header "support/alloc.h" header "support/atm.h" header "support/cpu.h" + header "support/json.h" header "support/log.h" header "support/log_windows.h" header "support/port_platform.h" diff --git a/include/grpc/support/json.h b/include/grpc/support/json.h new file mode 100644 index 00000000000..bae9268271f --- /dev/null +++ b/include/grpc/support/json.h @@ -0,0 +1,218 @@ +// +// Copyright 2015 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef GRPC_SUPPORT_JSON_H +#define GRPC_SUPPORT_JSON_H + +#include + +#include + +#include +#include +#include +#include + +#include "absl/strings/str_cat.h" +#include "absl/types/variant.h" + +namespace grpc_core { +namespace experimental { + +// A JSON value, which can be any one of null, boolean, number, string, +// object, or array. +class Json { + public: + // The JSON type. + enum class Type { + kNull, // No payload. Default type when using the zero-arg ctor. + kBoolean, // Use boolean() for payload. + kNumber, // Numbers are stored in string form to avoid precision + // and integer capacity issues. Use string() for payload. + kString, // Use string() for payload. + kObject, // Use object() for payload. + kArray, // Use array() for payload. + }; + + using Object = std::map; + using Array = std::vector; + + // Factory method for kBoolean. + static Json FromBool(bool b) { + Json json; + json.value_ = b; + return json; + } + + // Factory methods for kNumber. + static Json FromNumber(const std::string& str) { + Json json; + json.value_ = NumberValue{str}; + return json; + } + static Json FromNumber(const char* str) { + Json json; + json.value_ = NumberValue{std::string(str)}; + return json; + } + static Json FromNumber(std::string&& str) { + Json json; + json.value_ = NumberValue{std::move(str)}; + return json; + } + static Json FromNumber(int32_t value) { + Json json; + json.value_ = NumberValue{absl::StrCat(value)}; + return json; + } + static Json FromNumber(uint32_t value) { + Json json; + json.value_ = NumberValue{absl::StrCat(value)}; + return json; + } + static Json FromNumber(int64_t value) { + Json json; + json.value_ = NumberValue{absl::StrCat(value)}; + return json; + } + static Json FromNumber(uint64_t value) { + Json json; + json.value_ = NumberValue{absl::StrCat(value)}; + return json; + } + static Json FromNumber(double value) { + Json json; + json.value_ = NumberValue{absl::StrCat(value)}; + return json; + } + + // Factory methods for kString. + static Json FromString(const std::string& str) { + Json json; + json.value_ = str; + return json; + } + static Json FromString(const char* str) { + Json json; + json.value_ = std::string(str); + return json; + } + static Json FromString(std::string&& str) { + Json json; + json.value_ = std::move(str); + return json; + } + + // Factory methods for kObject. + static Json FromObject(const Object& object) { + Json json; + json.value_ = object; + return json; + } + static Json FromObject(Object&& object) { + Json json; + json.value_ = std::move(object); + return json; + } + + // Factory methods for kArray. + static Json FromArray(const Array& array) { + Json json; + json.value_ = array; + return json; + } + static Json FromArray(Array&& array) { + Json json; + json.value_ = std::move(array); + return json; + } + + Json() = default; + + // Copyable. + Json(const Json& other) = default; + Json& operator=(const Json& other) = default; + + // Moveable. + Json(Json&& other) noexcept : value_(std::move(other.value_)) { + other.value_ = absl::monostate(); + } + Json& operator=(Json&& other) noexcept { + value_ = std::move(other.value_); + other.value_ = absl::monostate(); + return *this; + } + + // Returns the JSON type. + Type type() const { + struct ValueFunctor { + Json::Type operator()(const absl::monostate&) { return Type::kNull; } + Json::Type operator()(bool) { return Type::kBoolean; } + Json::Type operator()(const NumberValue&) { return Type::kNumber; } + Json::Type operator()(const std::string&) { return Type::kString; } + Json::Type operator()(const Object&) { return Type::kObject; } + Json::Type operator()(const Array&) { return Type::kArray; } + }; + return absl::visit(ValueFunctor(), value_); + } + + // Payload accessor for kBoolean. + // Must not be called for other types. + bool boolean() const { return absl::get(value_); } + + // Payload accessor for kNumber or kString. + // Must not be called for other types. + const std::string& string() const { + const NumberValue* num = absl::get_if(&value_); + if (num != nullptr) return num->value; + return absl::get(value_); + } + + // Payload accessor for kObject. + // Must not be called for other types. + const Object& object() const { return absl::get(value_); } + + // Payload accessor for kArray. + // Must not be called for other types. + const Array& array() const { return absl::get(value_); } + + bool operator==(const Json& other) const { return value_ == other.value_; } + bool operator!=(const Json& other) const { return !(*this == other); } + + private: + struct NumberValue { + std::string value; + + bool operator==(const NumberValue& other) const { + return value == other.value; + } + }; + using Value = absl::variant; // kArray + + explicit Json(Value value) : value_(std::move(value)) {} + + Value value_; +}; + +} // namespace experimental +} // namespace grpc_core + +#endif // GRPC_SUPPORT_JSON_H diff --git a/package.xml b/package.xml index e5c030dec1f..ab97239ecfa 100644 --- a/package.xml +++ b/package.xml @@ -85,6 +85,7 @@ + diff --git a/src/core/BUILD b/src/core/BUILD index a16bd702233..62fba64e0f6 100644 --- a/src/core/BUILD +++ b/src/core/BUILD @@ -2758,7 +2758,6 @@ grpc_cc_library( "absl/strings:str_format", ], deps = [ - "json", "//:gpr", "//:grpc_base", ], @@ -3334,10 +3333,6 @@ grpc_cc_library( hdrs = [ "lib/json/json.h", ], - external_deps = [ - "absl/strings", - "absl/types:variant", - ], deps = ["//:gpr"], ) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 417566ef38b..be53eee5332 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include diff --git a/src/core/ext/filters/client_channel/client_channel_channelz.cc b/src/core/ext/filters/client_channel/client_channel_channelz.cc index b35fa3a6658..de36ab1a032 100644 --- a/src/core/ext/filters/client_channel/client_channel_channelz.cc +++ b/src/core/ext/filters/client_channel/client_channel_channelz.cc @@ -22,6 +22,8 @@ #include "absl/strings/str_cat.h" +#include + #include "src/core/lib/transport/connectivity_state.h" // IWYU pragma: no_include diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index c49f3a34fc2..d502e9552ec 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -54,6 +54,7 @@ #include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h" #include +#include // IWYU pragma: no_include diff --git a/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc b/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc index 9bbf1d83c52..7cda9b74a35 100644 --- a/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +++ b/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc @@ -61,6 +61,7 @@ #include #include #include +#include #include #include "src/core/ext/filters/client_channel/client_channel.h" diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc b/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc index 5f7709aa8ec..d048a5710d5 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc @@ -36,6 +36,7 @@ #include #include #include +#include #include #include "src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.h" diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc index 6bed406f28e..b6618b1f9c8 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc @@ -38,6 +38,7 @@ #include #include #include +#include #include #include "src/core/ext/filters/client_channel/lb_policy/address_filtering.h" diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds_wrr_locality.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds_wrr_locality.cc index 9bcdb0ddf1a..509aafe53b5 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds_wrr_locality.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_wrr_locality.cc @@ -30,6 +30,7 @@ #include #include +#include #include #include "src/core/ext/filters/client_channel/lb_policy/xds/xds_attributes.h" diff --git a/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc b/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc index 59a2ac7023b..f5089b54dcf 100644 --- a/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc @@ -29,6 +29,7 @@ #include "absl/strings/strip.h" #include "absl/types/optional.h" +#include #include #include "src/core/ext/gcp/metadata_query.h" diff --git a/src/core/ext/filters/client_channel/retry_service_config.cc b/src/core/ext/filters/client_channel/retry_service_config.cc index b26ad9e52c0..9743d000142 100644 --- a/src/core/ext/filters/client_channel/retry_service_config.cc +++ b/src/core/ext/filters/client_channel/retry_service_config.cc @@ -29,6 +29,7 @@ #include #include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/src/core/ext/xds/certificate_provider_store.cc b/src/core/ext/xds/certificate_provider_store.cc index 17bc9aa4832..1327e5a094d 100644 --- a/src/core/ext/xds/certificate_provider_store.cc +++ b/src/core/ext/xds/certificate_provider_store.cc @@ -22,6 +22,7 @@ #include "absl/strings/str_cat.h" +#include #include #include "src/core/lib/config/core_configuration.h" diff --git a/src/core/ext/xds/xds_audit_logger_registry.cc b/src/core/ext/xds/xds_audit_logger_registry.cc index 1d1562a402b..7481ddf689e 100644 --- a/src/core/ext/xds/xds_audit_logger_registry.cc +++ b/src/core/ext/xds/xds_audit_logger_registry.cc @@ -26,6 +26,8 @@ #include "envoy/config/core/v3/extension.upb.h" #include "envoy/config/rbac/v3/rbac.upb.h" +#include + #include "src/core/ext/xds/xds_common_types.h" #include "src/core/lib/gprpp/validation_errors.h" #include "src/core/lib/json/json.h" diff --git a/src/core/ext/xds/xds_bootstrap_grpc.cc b/src/core/ext/xds/xds_bootstrap_grpc.cc index 10ecb3f00f7..16676fda584 100644 --- a/src/core/ext/xds/xds_bootstrap_grpc.cc +++ b/src/core/ext/xds/xds_bootstrap_grpc.cc @@ -35,6 +35,8 @@ #include "absl/strings/string_view.h" #include "absl/types/optional.h" +#include + #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/json/json.h" diff --git a/src/core/ext/xds/xds_cluster.cc b/src/core/ext/xds/xds_cluster.cc index 657a8def93e..ad3773e6106 100644 --- a/src/core/ext/xds/xds_cluster.cc +++ b/src/core/ext/xds/xds_cluster.cc @@ -46,6 +46,7 @@ #include "upb/base/string_view.h" #include "upb/text/encode.h" +#include #include #include "src/core/ext/xds/upb_utils.h" diff --git a/src/core/ext/xds/xds_cluster_specifier_plugin.cc b/src/core/ext/xds/xds_cluster_specifier_plugin.cc index 8423da5446c..97b6229df39 100644 --- a/src/core/ext/xds/xds_cluster_specifier_plugin.cc +++ b/src/core/ext/xds/xds_cluster_specifier_plugin.cc @@ -30,6 +30,7 @@ #include "upb/json/encode.h" #include "upb/upb.hpp" +#include #include #include "src/core/lib/json/json.h" diff --git a/src/core/ext/xds/xds_common_types.cc b/src/core/ext/xds/xds_common_types.cc index 9e5de14f817..73985d17258 100644 --- a/src/core/ext/xds/xds_common_types.cc +++ b/src/core/ext/xds/xds_common_types.cc @@ -45,6 +45,8 @@ #include "upb/upb.hpp" #include "xds/type/v3/typed_struct.upb.h" +#include + #include "src/core/ext/xds/upb_utils.h" #include "src/core/ext/xds/xds_bootstrap_grpc.h" #include "src/core/ext/xds/xds_client.h" diff --git a/src/core/ext/xds/xds_http_fault_filter.cc b/src/core/ext/xds/xds_http_fault_filter.cc index 8e76f640fac..1950ca812cc 100644 --- a/src/core/ext/xds/xds_http_fault_filter.cc +++ b/src/core/ext/xds/xds_http_fault_filter.cc @@ -34,6 +34,7 @@ #include "google/protobuf/wrappers.upb.h" #include +#include #include "src/core/ext/filters/fault_injection/fault_injection_filter.h" #include "src/core/ext/filters/fault_injection/fault_injection_service_config_parser.h" diff --git a/src/core/ext/xds/xds_http_rbac_filter.cc b/src/core/ext/xds/xds_http_rbac_filter.cc index ab921369e0c..f7bde62b574 100644 --- a/src/core/ext/xds/xds_http_rbac_filter.cc +++ b/src/core/ext/xds/xds_http_rbac_filter.cc @@ -42,6 +42,8 @@ #include "google/protobuf/wrappers.upb.h" #include "upb/collections/map.h" +#include + #include "src/core/ext/filters/rbac/rbac_filter.h" #include "src/core/ext/filters/rbac/rbac_service_config_parser.h" #include "src/core/ext/xds/upb_utils.h" diff --git a/src/core/ext/xds/xds_http_stateful_session_filter.cc b/src/core/ext/xds/xds_http_stateful_session_filter.cc index 0bab0e1a2bc..85526a98d7e 100644 --- a/src/core/ext/xds/xds_http_stateful_session_filter.cc +++ b/src/core/ext/xds/xds_http_stateful_session_filter.cc @@ -31,6 +31,8 @@ #include "envoy/extensions/http/stateful_session/cookie/v3/cookie.upbdefs.h" #include "envoy/type/http/v3/cookie.upb.h" +#include + #include "src/core/ext/filters/stateful_session/stateful_session_filter.h" #include "src/core/ext/filters/stateful_session/stateful_session_service_config_parser.h" #include "src/core/ext/xds/upb_utils.h" diff --git a/src/core/ext/xds/xds_lb_policy_registry.cc b/src/core/ext/xds/xds_lb_policy_registry.cc index 58c512987c8..3cdff1af930 100644 --- a/src/core/ext/xds/xds_lb_policy_registry.cc +++ b/src/core/ext/xds/xds_lb_policy_registry.cc @@ -33,6 +33,8 @@ #include "envoy/extensions/load_balancing_policies/wrr_locality/v3/wrr_locality.upb.h" #include "google/protobuf/wrappers.upb.h" +#include + #include "src/core/ext/xds/xds_common_types.h" #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/gprpp/time.h" diff --git a/src/core/lib/channel/channel_trace.cc b/src/core/lib/channel/channel_trace.cc index f97ca6b219e..aa7913f1e55 100644 --- a/src/core/lib/channel/channel_trace.cc +++ b/src/core/lib/channel/channel_trace.cc @@ -26,6 +26,7 @@ #include "absl/strings/str_cat.h" #include +#include #include "src/core/lib/channel/channelz.h" #include "src/core/lib/gpr/string.h" diff --git a/src/core/lib/channel/channelz.cc b/src/core/lib/channel/channelz.cc index 31201dcfeaa..408dcd2af9a 100644 --- a/src/core/lib/channel/channelz.cc +++ b/src/core/lib/channel/channelz.cc @@ -29,6 +29,7 @@ #include "absl/strings/str_cat.h" #include "absl/strings/strip.h" +#include #include #include diff --git a/src/core/lib/channel/channelz_registry.cc b/src/core/lib/channel/channelz_registry.cc index 25f5e599d6c..aeef6de21fc 100644 --- a/src/core/lib/channel/channelz_registry.cc +++ b/src/core/lib/channel/channelz_registry.cc @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -205,7 +206,7 @@ char* grpc_channelz_get_server(intptr_t server_id) { grpc_core::Json json = grpc_core::Json::FromObject({ {"server", server_node->RenderJson()}, }); - return gpr_strdup(JsonDump(json).c_str()); + return gpr_strdup(grpc_core::JsonDump(json).c_str()); } char* grpc_channelz_get_server_sockets(intptr_t server_id, @@ -244,7 +245,7 @@ char* grpc_channelz_get_channel(intptr_t channel_id) { grpc_core::Json json = grpc_core::Json::FromObject({ {"channel", channel_node->RenderJson()}, }); - return gpr_strdup(JsonDump(json).c_str()); + return gpr_strdup(grpc_core::JsonDump(json).c_str()); } char* grpc_channelz_get_subchannel(intptr_t subchannel_id) { @@ -260,7 +261,7 @@ char* grpc_channelz_get_subchannel(intptr_t subchannel_id) { grpc_core::Json json = grpc_core::Json::FromObject({ {"subchannel", subchannel_node->RenderJson()}, }); - return gpr_strdup(JsonDump(json).c_str()); + return gpr_strdup(grpc_core::JsonDump(json).c_str()); } char* grpc_channelz_get_socket(intptr_t socket_id) { @@ -276,5 +277,5 @@ char* grpc_channelz_get_socket(intptr_t socket_id) { grpc_core::Json json = grpc_core::Json::FromObject({ {"socket", socket_node->RenderJson()}, }); - return gpr_strdup(JsonDump(json).c_str()); + return gpr_strdup(grpc_core::JsonDump(json).c_str()); } diff --git a/src/core/lib/json/json.h b/src/core/lib/json/json.h index 464ee03c4e9..ede3e818a9f 100644 --- a/src/core/lib/json/json.h +++ b/src/core/lib/json/json.h @@ -19,197 +19,11 @@ #include -#include - -#include -#include -#include -#include - -#include "absl/strings/str_cat.h" -#include "absl/types/variant.h" +#include namespace grpc_core { -// A JSON value, which can be any one of null, boolean, number, string, -// object, or array. -class Json { - public: - // The JSON type. - enum class Type { - kNull, // No payload. Default type when using the zero-arg ctor. - kBoolean, // Use boolean() for payload. - kNumber, // Numbers are stored in string form to avoid precision - // and integer capacity issues. Use string() for payload. - kString, // Use string() for payload. - kObject, // Use object() for payload. - kArray, // Use array() for payload. - }; - - using Object = std::map; - using Array = std::vector; - - // Factory method for kBoolean. - static Json FromBool(bool b) { - Json json; - json.value_ = b; - return json; - } - - // Factory methods for kNumber. - static Json FromNumber(const std::string& str) { - Json json; - json.value_ = NumberValue{str}; - return json; - } - static Json FromNumber(const char* str) { - Json json; - json.value_ = NumberValue{std::string(str)}; - return json; - } - static Json FromNumber(std::string&& str) { - Json json; - json.value_ = NumberValue{std::move(str)}; - return json; - } - static Json FromNumber(int32_t value) { - Json json; - json.value_ = NumberValue{absl::StrCat(value)}; - return json; - } - static Json FromNumber(uint32_t value) { - Json json; - json.value_ = NumberValue{absl::StrCat(value)}; - return json; - } - static Json FromNumber(int64_t value) { - Json json; - json.value_ = NumberValue{absl::StrCat(value)}; - return json; - } - static Json FromNumber(uint64_t value) { - Json json; - json.value_ = NumberValue{absl::StrCat(value)}; - return json; - } - static Json FromNumber(double value) { - Json json; - json.value_ = NumberValue{absl::StrCat(value)}; - return json; - } - - // Factory methods for kString. - static Json FromString(const std::string& str) { - Json json; - json.value_ = str; - return json; - } - static Json FromString(const char* str) { - Json json; - json.value_ = std::string(str); - return json; - } - static Json FromString(std::string&& str) { - Json json; - json.value_ = std::move(str); - return json; - } - - // Factory methods for kObject. - static Json FromObject(const Object& object) { - Json json; - json.value_ = object; - return json; - } - static Json FromObject(Object&& object) { - Json json; - json.value_ = std::move(object); - return json; - } - - // Factory methods for kArray. - static Json FromArray(const Array& array) { - Json json; - json.value_ = array; - return json; - } - static Json FromArray(Array&& array) { - Json json; - json.value_ = std::move(array); - return json; - } - - Json() = default; - - // Copyable. - Json(const Json& other) = default; - Json& operator=(const Json& other) = default; - - // Moveable. - Json(Json&& other) noexcept : value_(std::move(other.value_)) { - other.value_ = absl::monostate(); - } - Json& operator=(Json&& other) noexcept { - value_ = std::move(other.value_); - other.value_ = absl::monostate(); - return *this; - } - - // Returns the JSON type. - Type type() const { - struct ValueFunctor { - Json::Type operator()(const absl::monostate&) { return Type::kNull; } - Json::Type operator()(bool) { return Type::kBoolean; } - Json::Type operator()(const NumberValue&) { return Type::kNumber; } - Json::Type operator()(const std::string&) { return Type::kString; } - Json::Type operator()(const Object&) { return Type::kObject; } - Json::Type operator()(const Array&) { return Type::kArray; } - }; - return absl::visit(ValueFunctor(), value_); - } - - // Payload accessor for kBoolean. - // Must not be called for other types. - bool boolean() const { return absl::get(value_); } - - // Payload accessor for kNumber or kString. - // Must not be called for other types. - const std::string& string() const { - const NumberValue* num = absl::get_if(&value_); - if (num != nullptr) return num->value; - return absl::get(value_); - } - - // Payload accessor for kObject. - // Must not be called for other types. - const Object& object() const { return absl::get(value_); } - - // Payload accessor for kArray. - // Must not be called for other types. - const Array& array() const { return absl::get(value_); } - - bool operator==(const Json& other) const { return value_ == other.value_; } - bool operator!=(const Json& other) const { return !(*this == other); } - - private: - struct NumberValue { - std::string value; - - bool operator==(const NumberValue& other) const { - return value == other.value; - } - }; - using Value = absl::variant; // kArray - - explicit Json(Value value) : value_(std::move(value)) {} - - Value value_; -}; +using Json = experimental::Json; } // namespace grpc_core diff --git a/src/core/lib/json/json_reader.cc b/src/core/lib/json/json_reader.cc index 865364a5171..41d716f7fe3 100644 --- a/src/core/lib/json/json_reader.cc +++ b/src/core/lib/json/json_reader.cc @@ -35,6 +35,7 @@ #include "absl/strings/string_view.h" #include "absl/types/variant.h" +#include #include #include "src/core/lib/gprpp/match.h" diff --git a/src/core/lib/load_balancing/lb_policy_registry.cc b/src/core/lib/load_balancing/lb_policy_registry.cc index dd74c379b3c..de6466348b5 100644 --- a/src/core/lib/load_balancing/lb_policy_registry.cc +++ b/src/core/lib/load_balancing/lb_policy_registry.cc @@ -31,6 +31,7 @@ #include "absl/strings/str_join.h" #include "absl/strings/string_view.h" +#include #include #include "src/core/lib/load_balancing/lb_policy.h" diff --git a/src/core/lib/security/authorization/audit_logging.cc b/src/core/lib/security/authorization/audit_logging.cc index 2be619fff1e..f390faa9528 100644 --- a/src/core/lib/security/authorization/audit_logging.cc +++ b/src/core/lib/security/authorization/audit_logging.cc @@ -34,7 +34,6 @@ #include #include "src/core/lib/gprpp/sync.h" -#include "src/core/lib/json/json.h" namespace grpc_core { namespace experimental { diff --git a/src/core/lib/security/authorization/audit_logging.h b/src/core/lib/security/authorization/audit_logging.h index 55087b0a5d6..43a01d51d51 100644 --- a/src/core/lib/security/authorization/audit_logging.h +++ b/src/core/lib/security/authorization/audit_logging.h @@ -29,9 +29,9 @@ #include "absl/strings/string_view.h" #include +#include #include "src/core/lib/gprpp/sync.h" -#include "src/core/lib/json/json.h" namespace grpc_core { namespace experimental { diff --git a/src/core/lib/security/authorization/rbac_translator.cc b/src/core/lib/security/authorization/rbac_translator.cc index d73f9c24a7c..8134a394920 100644 --- a/src/core/lib/security/authorization/rbac_translator.cc +++ b/src/core/lib/security/authorization/rbac_translator.cc @@ -35,6 +35,7 @@ #include "absl/strings/strip.h" #include +#include #include #include "src/core/lib/gpr/useful.h" diff --git a/src/core/lib/security/credentials/external/aws_external_account_credentials.cc b/src/core/lib/security/credentials/external/aws_external_account_credentials.cc index 0a7f7636269..5ba5d64ea02 100644 --- a/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +++ b/src/core/lib/security/credentials/external/aws_external_account_credentials.cc @@ -34,6 +34,7 @@ #include #include #include +#include #include #include diff --git a/src/core/lib/security/credentials/external/external_account_credentials.cc b/src/core/lib/security/credentials/external/external_account_credentials.cc index 4bcdc13a9dc..fbe8d78b1c1 100644 --- a/src/core/lib/security/credentials/external/external_account_credentials.cc +++ b/src/core/lib/security/credentials/external/external_account_credentials.cc @@ -40,6 +40,7 @@ #include #include #include +#include #include #include diff --git a/src/core/lib/security/credentials/external/file_external_account_credentials.cc b/src/core/lib/security/credentials/external/file_external_account_credentials.cc index 3f31304e75a..e70131bfeef 100644 --- a/src/core/lib/security/credentials/external/file_external_account_credentials.cc +++ b/src/core/lib/security/credentials/external/file_external_account_credentials.cc @@ -25,6 +25,7 @@ #include "absl/strings/string_view.h" #include +#include #include "src/core/lib/iomgr/load_file.h" #include "src/core/lib/json/json.h" diff --git a/src/core/lib/security/credentials/external/url_external_account_credentials.cc b/src/core/lib/security/credentials/external/url_external_account_credentials.cc index 3e637ee5b76..8f257a1b8ef 100644 --- a/src/core/lib/security/credentials/external/url_external_account_credentials.cc +++ b/src/core/lib/security/credentials/external/url_external_account_credentials.cc @@ -33,6 +33,7 @@ #include #include #include +#include #include #include diff --git a/src/core/lib/security/credentials/google_default/google_default_credentials.cc b/src/core/lib/security/credentials/google_default/google_default_credentials.cc index 63e181c2e0b..6d2eb20cda3 100644 --- a/src/core/lib/security/credentials/google_default/google_default_credentials.cc +++ b/src/core/lib/security/credentials/google_default/google_default_credentials.cc @@ -34,6 +34,7 @@ #include #include #include +#include #include #include diff --git a/src/core/lib/security/credentials/jwt/json_token.cc b/src/core/lib/security/credentials/jwt/json_token.cc index 1380d3e8bb1..94cd962ec0b 100644 --- a/src/core/lib/security/credentials/jwt/json_token.cc +++ b/src/core/lib/security/credentials/jwt/json_token.cc @@ -36,6 +36,7 @@ #include #include +#include #include #include @@ -170,7 +171,7 @@ static char* encoded_jwt_header(const char* key_id, const char* algorithm) { {"typ", Json::FromString(GRPC_JWT_TYPE)}, {"kid", Json::FromString(key_id)}, }); - std::string json_str = JsonDump(json); + std::string json_str = grpc_core::JsonDump(json); return grpc_base64_encode(json_str.c_str(), json_str.size(), 1, 0); } @@ -197,7 +198,8 @@ static char* encoded_jwt_claim(const grpc_auth_json_key* json_key, object["sub"] = Json::FromString(json_key->client_email); } - std::string json_str = JsonDump(Json::FromObject(std::move(object))); + std::string json_str = + grpc_core::JsonDump(Json::FromObject(std::move(object))); return grpc_base64_encode(json_str.c_str(), json_str.size(), 1, 0); } diff --git a/src/core/lib/security/credentials/jwt/jwt_credentials.cc b/src/core/lib/security/credentials/jwt/jwt_credentials.cc index 037bda05264..c92c0f028b1 100644 --- a/src/core/lib/security/credentials/jwt/jwt_credentials.cc +++ b/src/core/lib/security/credentials/jwt/jwt_credentials.cc @@ -30,6 +30,7 @@ #include "absl/strings/str_cat.h" #include +#include #include #include #include diff --git a/src/core/lib/security/credentials/jwt/jwt_verifier.cc b/src/core/lib/security/credentials/jwt/jwt_verifier.cc index f52f9591844..cb5086b2138 100644 --- a/src/core/lib/security/credentials/jwt/jwt_verifier.cc +++ b/src/core/lib/security/credentials/jwt/jwt_verifier.cc @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc index 84cd582a496..79b0cce1e54 100644 --- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include diff --git a/src/core/lib/security/util/json_util.cc b/src/core/lib/security/util/json_util.cc index 69b7fbecc76..1eb33a16fc3 100644 --- a/src/core/lib/security/util/json_util.cc +++ b/src/core/lib/security/util/json_util.cc @@ -26,6 +26,7 @@ #include "absl/strings/str_cat.h" +#include #include #include "src/core/lib/iomgr/error.h" diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc index d8f1a42a884..dadebcbfd67 100644 --- a/src/cpp/client/secure_credentials.cc +++ b/src/cpp/client/secure_credentials.cc @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include diff --git a/test/core/channel/channelz_test.cc b/test/core/channel/channelz_test.cc index 12c4e6d49b8..f9f4ac828dd 100644 --- a/test/core/channel/channelz_test.cc +++ b/test/core/channel/channelz_test.cc @@ -32,6 +32,7 @@ #include #include #include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/client_channel/lb_policy/outlier_detection_test.cc b/test/core/client_channel/lb_policy/outlier_detection_test.cc index 82281cd0b66..a50d6f34ef5 100644 --- a/test/core/client_channel/lb_policy/outlier_detection_test.cc +++ b/test/core/client_channel/lb_policy/outlier_detection_test.cc @@ -25,6 +25,7 @@ #include "gtest/gtest.h" #include +#include #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" diff --git a/test/core/client_channel/lb_policy/weighted_round_robin_test.cc b/test/core/client_channel/lb_policy/weighted_round_robin_test.cc index 50ff918dc6c..036abcdd921 100644 --- a/test/core/client_channel/lb_policy/weighted_round_robin_test.cc +++ b/test/core/client_channel/lb_policy/weighted_round_robin_test.cc @@ -40,6 +40,7 @@ #include #include +#include #include #include "src/core/ext/filters/client_channel/lb_policy/backend_metric_data.h" diff --git a/test/core/client_channel/lb_policy/xds_override_host_test.cc b/test/core/client_channel/lb_policy/xds_override_host_test.cc index f342e60eecb..ba920ef0157 100644 --- a/test/core/client_channel/lb_policy/xds_override_host_test.cc +++ b/test/core/client_channel/lb_policy/xds_override_host_test.cc @@ -31,6 +31,7 @@ #include "gtest/gtest.h" #include +#include #include "src/core/ext/filters/stateful_session/stateful_session_filter.h" #include "src/core/ext/xds/xds_health_status.h" diff --git a/test/core/json/fuzzer.cc b/test/core/json/fuzzer.cc index dcd67bce59f..ba311c4f473 100644 --- a/test/core/json/fuzzer.cc +++ b/test/core/json/fuzzer.cc @@ -22,6 +22,7 @@ #include "absl/status/statusor.h" #include "absl/strings/string_view.h" +#include #include #include "src/core/lib/json/json.h" @@ -35,7 +36,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { auto json = grpc_core::JsonParse( absl::string_view(reinterpret_cast(data), size)); if (json.ok()) { - auto text2 = JsonDump(*json); + auto text2 = grpc_core::JsonDump(*json); auto json2 = grpc_core::JsonParse(text2); GPR_ASSERT(json2.ok()); GPR_ASSERT(*json == *json2); diff --git a/test/core/json/json_object_loader_test.cc b/test/core/json/json_object_loader_test.cc index 7b54338920c..ed47750b434 100644 --- a/test/core/json/json_object_loader_test.cc +++ b/test/core/json/json_object_loader_test.cc @@ -20,6 +20,8 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" +#include + #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/json/json_reader.h" diff --git a/test/core/json/json_test.cc b/test/core/json/json_test.cc index 257fd3a16c2..4ebe593b821 100644 --- a/test/core/json/json_test.cc +++ b/test/core/json/json_test.cc @@ -18,6 +18,10 @@ #include +#include +#include +#include + #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/match.h" diff --git a/test/core/security/verify_jwt.cc b/test/core/security/verify_jwt.cc index 007ada0744b..9b64fc8e124 100644 --- a/test/core/security/verify_jwt.cc +++ b/test/core/security/verify_jwt.cc @@ -57,7 +57,7 @@ static void on_jwt_verification_done(void* user_data, if (sync->success) { GPR_ASSERT(claims != nullptr); std::string claims_str = - JsonDump(*grpc_jwt_claims_json(claims), /*indent=*/2); + grpc_core::JsonDump(*grpc_jwt_claims_json(claims), /*indent=*/2); printf("Claims: \n\n%s\n", claims_str.c_str()); grpc_jwt_claims_destroy(claims); } else { diff --git a/test/core/xds/xds_bootstrap_test.cc b/test/core/xds/xds_bootstrap_test.cc index 3a881fe216c..bdb7707427e 100644 --- a/test/core/xds/xds_bootstrap_test.cc +++ b/test/core/xds/xds_bootstrap_test.cc @@ -37,6 +37,7 @@ #include #include #include +#include #include "src/core/ext/xds/certificate_provider_store.h" #include "src/core/ext/xds/xds_bootstrap_grpc.h" diff --git a/test/core/xds/xds_client_test.cc b/test/core/xds/xds_client_test.cc index 447add79272..4567dad47f6 100644 --- a/test/core/xds/xds_client_test.cc +++ b/test/core/xds/xds_client_test.cc @@ -40,6 +40,7 @@ #include "upb/reflection/def.h" #include +#include #include #include diff --git a/test/core/xds/xds_http_filters_test.cc b/test/core/xds/xds_http_filters_test.cc index 5d683d9d61b..20e8888a672 100644 --- a/test/core/xds/xds_http_filters_test.cc +++ b/test/core/xds/xds_http_filters_test.cc @@ -38,6 +38,7 @@ #include #include +#include #include #include diff --git a/test/cpp/util/channel_trace_proto_helper.cc b/test/cpp/util/channel_trace_proto_helper.cc index 0539d85fd8e..a4c22182476 100644 --- a/test/cpp/util/channel_trace_proto_helper.cc +++ b/test/cpp/util/channel_trace_proto_helper.cc @@ -66,7 +66,7 @@ void VaidateProtoJsonTranslation(const std::string& json_str) { auto parsed_json = grpc_core::JsonParse(proto_json_str.c_str()); ASSERT_TRUE(parsed_json.ok()) << parsed_json.status(); ASSERT_EQ(parsed_json->type(), grpc_core::Json::Type::kObject); - proto_json_str = JsonDump(*parsed_json); + proto_json_str = grpc_core::JsonDump(*parsed_json); EXPECT_EQ(json_str, proto_json_str); } diff --git a/test/cpp/util/channelz_sampler.cc b/test/cpp/util/channelz_sampler.cc index 34181e6bf8f..60c0e126ded 100644 --- a/test/cpp/util/channelz_sampler.cc +++ b/test/cpp/util/channelz_sampler.cc @@ -535,7 +535,9 @@ class ChannelzSampler final { } // Dump data in json - std::string DumpJson() { return JsonDump(grpc_core::Json::FromArray(json_)); } + std::string DumpJson() { + return grpc_core::JsonDump(grpc_core::Json::FromArray(json_)); + } // Check if one entity has been recorded bool CheckID(int64_t id) { diff --git a/tools/distrib/check_include_guards.py b/tools/distrib/check_include_guards.py index 47ecc08e218..71cae463bef 100755 --- a/tools/distrib/check_include_guards.py +++ b/tools/distrib/check_include_guards.py @@ -55,8 +55,10 @@ class GuardValidator(object): self.failed = False def _is_c_core_header(self, fpath): - return 'include' in fpath and not ('grpc++' in fpath or 'grpcpp' - in fpath or 'event_engine' in fpath) + return 'include' in fpath and not ( + 'grpc++' in fpath or 'grpcpp' in fpath or 'event_engine' in fpath or + fpath.endswith('/grpc_audit_logging.h') or + fpath.endswith('/json.h')) def fail(self, fpath, regexp, fcontents, match_txt, correct, fix): c_core_header = self._is_c_core_header(fpath) diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index c161f81df10..8511964e8ed 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -931,6 +931,7 @@ include/grpc/support/atm_gcc_atomic.h \ include/grpc/support/atm_gcc_sync.h \ include/grpc/support/atm_windows.h \ include/grpc/support/cpu.h \ +include/grpc/support/json.h \ include/grpc/support/log.h \ include/grpc/support/log_windows.h \ include/grpc/support/port_platform.h \ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index bf4705be6a7..b43cf2fbad2 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -931,6 +931,7 @@ include/grpc/support/atm_gcc_atomic.h \ include/grpc/support/atm_gcc_sync.h \ include/grpc/support/atm_windows.h \ include/grpc/support/cpu.h \ +include/grpc/support/json.h \ include/grpc/support/log.h \ include/grpc/support/log_windows.h \ include/grpc/support/port_platform.h \ diff --git a/tools/doxygen/Doxyfile.core b/tools/doxygen/Doxyfile.core index f7952437ff8..d87c70e1772 100644 --- a/tools/doxygen/Doxyfile.core +++ b/tools/doxygen/Doxyfile.core @@ -864,6 +864,7 @@ include/grpc/support/atm_gcc_atomic.h \ include/grpc/support/atm_gcc_sync.h \ include/grpc/support/atm_windows.h \ include/grpc/support/cpu.h \ +include/grpc/support/json.h \ include/grpc/support/log.h \ include/grpc/support/log_windows.h \ include/grpc/support/port_platform.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index fc320f56a68..70615314d95 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -864,6 +864,7 @@ include/grpc/support/atm_gcc_atomic.h \ include/grpc/support/atm_gcc_sync.h \ include/grpc/support/atm_windows.h \ include/grpc/support/cpu.h \ +include/grpc/support/json.h \ include/grpc/support/log.h \ include/grpc/support/log_windows.h \ include/grpc/support/port_platform.h \