MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / MapValueToJsonObject

Function MapValueToJsonObject

common/values/value_builder.cc:806–831  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

804
805template <typename Map>
806absl::Status MapValueToJsonObject(
807 const Map& map, const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool,
808 google::protobuf::MessageFactory* absl_nonnull message_factory,
809 google::protobuf::Message* absl_nonnull json) {
810 ABSL_DCHECK(descriptor_pool != nullptr);
811 ABSL_DCHECK(message_factory != nullptr);
812 ABSL_DCHECK(json != nullptr);
813 ABSL_DCHECK_EQ(json->GetDescriptor()->well_known_type(),
814 google::protobuf::Descriptor::WELLKNOWNTYPE_STRUCT);
815
816 StructReflection reflection;
817 CEL_RETURN_IF_ERROR(reflection.Initialize(json->GetDescriptor()));
818
819 json->Clear();
820
821 if (map.empty()) {
822 return absl::OkStatus();
823 }
824
825 for (const auto& entry : map) {
826 CEL_ASSIGN_OR_RETURN(auto key, ValueToJsonString(entry.first));
827 CEL_RETURN_IF_ERROR(entry.second.ConvertToJson(
828 descriptor_pool, message_factory, reflection.InsertField(json, key)));
829 }
830 return absl::OkStatus();
831}
832
833template <typename Map>
834absl::Status MapValueToJson(

Callers 3

MapValueToJsonFunction · 0.85
ConvertToJsonObjectMethod · 0.85
ConvertToJsonObjectMethod · 0.85

Calls 6

GetDescriptorMethod · 0.45
InitializeMethod · 0.45
ClearMethod · 0.45
emptyMethod · 0.45
ConvertToJsonMethod · 0.45
InsertFieldMethod · 0.45

Tested by

no test coverage detected