From d78e0b249d755bc885b2c6735c2858b1300f3df4 Mon Sep 17 00:00:00 2001 From: Aaditya Srinivasan Date: Sun, 26 Jul 2026 17:49:11 +0530 Subject: [PATCH 1/4] GH-35460: Migrate ObjectWriter users to JsonWriter --- cpp/src/arrow/CMakeLists.txt | 2 +- cpp/src/arrow/json/meson.build | 1 - cpp/src/arrow/json/object_writer.cc | 81 ------------------- cpp/src/arrow/json/object_writer.h | 49 ----------- cpp/src/arrow/meson.build | 1 - cpp/src/parquet/CMakeLists.txt | 6 +- .../file_system_key_material_store.cc | 11 ++- cpp/src/parquet/encryption/key_material.cc | 53 ++++++++---- cpp/src/parquet/encryption/key_metadata.cc | 23 ++++-- .../encryption/local_wrap_kms_client.cc | 19 +++-- 10 files changed, 76 insertions(+), 170 deletions(-) delete mode 100644 cpp/src/arrow/json/object_writer.cc delete mode 100644 cpp/src/arrow/json/object_writer.h diff --git a/cpp/src/arrow/CMakeLists.txt b/cpp/src/arrow/CMakeLists.txt index 64fb4d12a546..2d23e1d8e450 100644 --- a/cpp/src/arrow/CMakeLists.txt +++ b/cpp/src/arrow/CMakeLists.txt @@ -1042,7 +1042,7 @@ if(ARROW_JSON) json/from_string.cc json/json_writer_internal.cc json/object_parser.cc - json/object_writer.cc + json/json_writer.cc json/parser.cc json/reader.cc) foreach(ARROW_JSON_TARGET ${ARROW_JSON_TARGETS}) diff --git a/cpp/src/arrow/json/meson.build b/cpp/src/arrow/json/meson.build index a2aa69ecf789..e5ebcc8ee023 100644 --- a/cpp/src/arrow/json/meson.build +++ b/cpp/src/arrow/json/meson.build @@ -45,7 +45,6 @@ install_headers( 'converter.h', 'from_string.h', 'object_parser.h', - 'object_writer.h', 'options.h', 'parser.h', 'rapidjson_defs.h', diff --git a/cpp/src/arrow/json/object_writer.cc b/cpp/src/arrow/json/object_writer.cc deleted file mode 100644 index 3277807880ce..000000000000 --- a/cpp/src/arrow/json/object_writer.cc +++ /dev/null @@ -1,81 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you 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. - -#include "arrow/json/object_writer.h" -#include "arrow/json/rapidjson_defs.h" // IWYU pragma: keep - -#include -#include -#include - -namespace rj = arrow::rapidjson; - -namespace arrow { -namespace json { -namespace internal { - -class ObjectWriter::Impl { - public: - Impl() : root_(rj::kObjectType) {} - - void SetString(std::string_view key, std::string_view value) { - rj::Document::AllocatorType& allocator = document_.GetAllocator(); - - rj::Value str_key(key.data(), allocator); - rj::Value str_value(value.data(), allocator); - - root_.AddMember(str_key, str_value, allocator); - } - - void SetBool(std::string_view key, bool value) { - rj::Document::AllocatorType& allocator = document_.GetAllocator(); - - rj::Value str_key(key.data(), allocator); - - root_.AddMember(str_key, value, allocator); - } - - std::string Serialize() { - rj::StringBuffer buffer; - rj::Writer writer(buffer); - root_.Accept(writer); - - return buffer.GetString(); - } - - private: - rj::Document document_; - rj::Value root_; -}; - -ObjectWriter::ObjectWriter() : impl_(new ObjectWriter::Impl()) {} - -ObjectWriter::~ObjectWriter() = default; - -void ObjectWriter::SetString(std::string_view key, std::string_view value) { - impl_->SetString(key, value); -} - -void ObjectWriter::SetBool(std::string_view key, bool value) { - impl_->SetBool(key, value); -} - -std::string ObjectWriter::Serialize() { return impl_->Serialize(); } - -} // namespace internal -} // namespace json -} // namespace arrow diff --git a/cpp/src/arrow/json/object_writer.h b/cpp/src/arrow/json/object_writer.h deleted file mode 100644 index cf1ce62194fb..000000000000 --- a/cpp/src/arrow/json/object_writer.h +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you 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. - -#pragma once - -#include -#include -#include - -#include "arrow/util/visibility.h" - -namespace arrow { -namespace json { -namespace internal { - -/// This class is a helper to serialize a json object to a string. -/// It uses rapidjson in implementation. -class ARROW_EXPORT ObjectWriter { - public: - ObjectWriter(); - ~ObjectWriter(); - - void SetString(std::string_view key, std::string_view value); - void SetBool(std::string_view key, bool value); - - std::string Serialize(); - - private: - class Impl; - std::unique_ptr impl_; -}; - -} // namespace internal -} // namespace json -} // namespace arrow diff --git a/cpp/src/arrow/meson.build b/cpp/src/arrow/meson.build index ef044f6c4227..955ef78973ed 100644 --- a/cpp/src/arrow/meson.build +++ b/cpp/src/arrow/meson.build @@ -516,7 +516,6 @@ if needs_json 'json/from_string.cc', 'json/json_writer_internal.cc', 'json/object_parser.cc', - 'json/object_writer.cc', 'json/options.cc', 'json/parser.cc', 'json/reader.cc', diff --git a/cpp/src/parquet/CMakeLists.txt b/cpp/src/parquet/CMakeLists.txt index f8a42b5b96bf..e5860d891964 100644 --- a/cpp/src/parquet/CMakeLists.txt +++ b/cpp/src/parquet/CMakeLists.txt @@ -263,9 +263,9 @@ endif() list(APPEND PARQUET_SHARED_LINK_LIBS arrow_shared) -# Add RapidJSON libraries -list(APPEND PARQUET_SHARED_PRIVATE_LINK_LIBS RapidJSON) -list(APPEND PARQUET_STATIC_LINK_LIBS RapidJSON) +# Add RapidJSON & simdjson libraries +list(APPEND PARQUET_SHARED_PRIVATE_LINK_LIBS RapidJSON simdjson::simdjson) +list(APPEND PARQUET_STATIC_LINK_LIBS RapidJSON simdjson::simdjson) # These are libraries that we will link privately with parquet_shared (as they # do not need to be linked transitively by other linkers) diff --git a/cpp/src/parquet/encryption/file_system_key_material_store.cc b/cpp/src/parquet/encryption/file_system_key_material_store.cc index fb8c92ceafee..a8b1278b7ab4 100644 --- a/cpp/src/parquet/encryption/file_system_key_material_store.cc +++ b/cpp/src/parquet/encryption/file_system_key_material_store.cc @@ -20,8 +20,8 @@ #include "arrow/buffer.h" #include "arrow/filesystem/filesystem.h" #include "arrow/filesystem/path_util.h" +#include "arrow/json/json_writer_internal.h" #include "arrow/json/object_parser.h" -#include "arrow/json/object_writer.h" #include "arrow/result.h" #include "parquet/encryption/file_system_key_material_store.h" @@ -81,11 +81,14 @@ void FileSystemKeyMaterialStore::LoadKeyMaterialMap() { } std::string FileSystemKeyMaterialStore::BuildKeyMaterialMapJson() { - ::arrow::json::internal::ObjectWriter writer; + ::arrow::json::JsonWriter writer; + writer.StartObject(); for (const auto& it : key_material_map_) { - writer.SetString(it.first, it.second); + writer.Key(it.first); + writer.String(it.second); } - return writer.Serialize(); + writer.EndObject(); + return std::string(writer.GetString()); } void FileSystemKeyMaterialStore::SaveMaterial() { diff --git a/cpp/src/parquet/encryption/key_material.cc b/cpp/src/parquet/encryption/key_material.cc index 1cebf5900f31..76f011e7adc7 100644 --- a/cpp/src/parquet/encryption/key_material.cc +++ b/cpp/src/parquet/encryption/key_material.cc @@ -15,15 +15,15 @@ // specific language governing permissions and limitations // under the License. +#include "arrow/json/json_writer_internal.h" #include "arrow/json/object_parser.h" -#include "arrow/json/object_writer.h" #include "parquet/encryption/key_material.h" #include "parquet/encryption/key_metadata.h" #include "parquet/exception.h" using ::arrow::json::internal::ObjectParser; -using ::arrow::json::internal::ObjectWriter; +using ::arrow::json::JsonWriter; namespace parquet::encryption { @@ -122,36 +122,57 @@ std::string KeyMaterial::SerializeToJson( bool is_double_wrapped, const std::string& kek_id, const std::string& encoded_wrapped_kek, const std::string& encoded_wrapped_dek, bool is_internal_storage) { - ObjectWriter json_writer; - json_writer.SetString(kKeyMaterialTypeField, kKeyMaterialType1); + JsonWriter json_writer; + + json_writer.StartObject(); + + json_writer.Key(kKeyMaterialTypeField); + json_writer.String(kKeyMaterialType1); if (is_internal_storage) { - // 1. for internal storage, key material and key metadata are the same. - // adding the "internalStorage" field that belongs to KeyMetadata. - json_writer.SetBool(KeyMetadata::kKeyMaterialInternalStorageField, true); + json_writer.Key(KeyMetadata::kKeyMaterialInternalStorageField); + json_writer.Bool(true); } + // 2. Write isFooterKey - json_writer.SetBool(kIsFooterKeyField, is_footer_key); + json_writer.Key(kIsFooterKeyField); + json_writer.Bool(is_footer_key); + if (is_footer_key) { // 3. For footer key, write KMS Instance ID - json_writer.SetString(kKmsInstanceIdField, kms_instance_id); + json_writer.Key(kKmsInstanceIdField); + json_writer.String(kms_instance_id); + // 4. For footer key, write KMS Instance URL - json_writer.SetString(kKmsInstanceUrlField, kms_instance_url); + json_writer.Key(kKmsInstanceUrlField); + json_writer.String(kms_instance_url); } + // 5. Write master key ID - json_writer.SetString(kMasterKeyIdField, master_key_id); + json_writer.Key(kMasterKeyIdField); + json_writer.String(master_key_id); + // 6. Write wrapped DEK - json_writer.SetString(kWrappedDataEncryptionKeyField, encoded_wrapped_dek); + json_writer.Key(kWrappedDataEncryptionKeyField); + json_writer.String(encoded_wrapped_dek); + // 7. Write isDoubleWrapped - json_writer.SetBool(kDoubleWrappingField, is_double_wrapped); + json_writer.Key(kDoubleWrappingField); + json_writer.Bool(is_double_wrapped); + if (is_double_wrapped) { // 8. In double wrapping mode, write KEK ID - json_writer.SetString(kKeyEncryptionKeyIdField, kek_id); + json_writer.Key(kKeyEncryptionKeyIdField); + json_writer.String(kek_id); + // 9. In double wrapping mode, write wrapped KEK - json_writer.SetString(kWrappedKeyEncryptionKeyField, encoded_wrapped_kek); + json_writer.Key(kWrappedKeyEncryptionKeyField); + json_writer.String(encoded_wrapped_kek); } - return json_writer.Serialize(); + json_writer.EndObject(); + + return std::string(json_writer.GetString()); } } // namespace parquet::encryption diff --git a/cpp/src/parquet/encryption/key_metadata.cc b/cpp/src/parquet/encryption/key_metadata.cc index e23a67b6b86e..fdd52aafd118 100644 --- a/cpp/src/parquet/encryption/key_metadata.cc +++ b/cpp/src/parquet/encryption/key_metadata.cc @@ -15,14 +15,14 @@ // specific language governing permissions and limitations // under the License. +#include "arrow/json/json_writer_internal.h" #include "arrow/json/object_parser.h" -#include "arrow/json/object_writer.h" #include "parquet/encryption/key_metadata.h" #include "parquet/exception.h" using ::arrow::json::internal::ObjectParser; -using ::arrow::json::internal::ObjectWriter; +using ::arrow::json::JsonWriter; namespace parquet::encryption { @@ -73,15 +73,22 @@ KeyMetadata KeyMetadata::Parse(const std::string& key_metadata) { // directly std::string KeyMetadata::CreateSerializedForExternalMaterial( const std::string& key_reference) { - ObjectWriter json_writer; + JsonWriter json_writer; - json_writer.SetString(KeyMaterial::kKeyMaterialTypeField, - KeyMaterial::kKeyMaterialType1); - json_writer.SetBool(kKeyMaterialInternalStorageField, false); + json_writer.StartObject(); - json_writer.SetString(kKeyReferenceField, key_reference); + json_writer.Key(KeyMaterial::kKeyMaterialTypeField); + json_writer.String(KeyMaterial::kKeyMaterialType1); - return json_writer.Serialize(); + json_writer.Key(kKeyMaterialInternalStorageField); + json_writer.Bool(false); + + json_writer.Key(kKeyReferenceField); + json_writer.String(key_reference); + + json_writer.EndObject(); + + return std::string(json_writer.GetString()); } } // namespace parquet::encryption diff --git a/cpp/src/parquet/encryption/local_wrap_kms_client.cc b/cpp/src/parquet/encryption/local_wrap_kms_client.cc index 80543c2932aa..10c7928c9d76 100644 --- a/cpp/src/parquet/encryption/local_wrap_kms_client.cc +++ b/cpp/src/parquet/encryption/local_wrap_kms_client.cc @@ -15,8 +15,8 @@ // specific language governing permissions and limitations // under the License. +#include "arrow/json/json_writer_internal.h" #include "arrow/json/object_parser.h" -#include "arrow/json/object_writer.h" #include "arrow/util/secure_string.h" #include "parquet/encryption/key_toolkit_internal.h" @@ -24,7 +24,7 @@ #include "parquet/exception.h" using ::arrow::json::internal::ObjectParser; -using ::arrow::json::internal::ObjectWriter; +using ::arrow::json::JsonWriter; using ::arrow::util::SecureString; namespace parquet::encryption { @@ -41,12 +41,19 @@ LocalWrapKmsClient::LocalKeyWrap::LocalKeyWrap(std::string master_key_version, std::string LocalWrapKmsClient::LocalKeyWrap::CreateSerialized( const std::string& encrypted_encoded_key) { - ObjectWriter json_writer; + JsonWriter json_writer; - json_writer.SetString(kLocalWrapKeyVersionField, kLocalWrapNoKeyVersion); - json_writer.SetString(kLocalWrapEncryptedKeyField, encrypted_encoded_key); + json_writer.StartObject(); - return json_writer.Serialize(); + json_writer.Key(kLocalWrapKeyVersionField); + json_writer.String(kLocalWrapNoKeyVersion); + + json_writer.Key(kLocalWrapEncryptedKeyField); + json_writer.String(encrypted_encoded_key); + + json_writer.EndObject(); + + return std::string(json_writer.GetString()); } LocalWrapKmsClient::LocalKeyWrap LocalWrapKmsClient::LocalKeyWrap::Parse( From 7c88575fa8915654014aba7b3680bf576286ea73 Mon Sep 17 00:00:00 2001 From: Aaditya Srinivasan Date: Tue, 28 Jul 2026 21:17:57 +0530 Subject: [PATCH 2/4] Sort order --- cpp/src/arrow/json/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/src/arrow/json/meson.build b/cpp/src/arrow/json/meson.build index e5ebcc8ee023..edf92a46fdd2 100644 --- a/cpp/src/arrow/json/meson.build +++ b/cpp/src/arrow/json/meson.build @@ -22,9 +22,9 @@ exc = executable( 'chunker_test.cc', 'converter_test.cc', 'from_string_test.cc', + 'json_writer_internal_test.cc', 'parser_test.cc', 'reader_test.cc', - 'json_writer_internal_test.cc', ], dependencies: [arrow_test_dep, rapidjson_dep], ) From 19376a044eb9ff60dc9ccd39b1e4fb777f243a43 Mon Sep 17 00:00:00 2001 From: Aaditya Srinivasan Date: Tue, 28 Jul 2026 22:20:08 +0530 Subject: [PATCH 3/4] Addressed Review Comments --- cpp/src/arrow/CMakeLists.txt | 1 - cpp/src/arrow/json/json_writer_internal.cc | 10 ++++++ cpp/src/arrow/json/json_writer_internal.h | 4 +++ .../file_system_key_material_store.cc | 3 +- cpp/src/parquet/encryption/key_material.cc | 35 +++++++------------ cpp/src/parquet/encryption/key_metadata.cc | 14 +++----- .../encryption/local_wrap_kms_client.cc | 9 ++--- 7 files changed, 36 insertions(+), 40 deletions(-) diff --git a/cpp/src/arrow/CMakeLists.txt b/cpp/src/arrow/CMakeLists.txt index 2d23e1d8e450..7211bf5476dc 100644 --- a/cpp/src/arrow/CMakeLists.txt +++ b/cpp/src/arrow/CMakeLists.txt @@ -1042,7 +1042,6 @@ if(ARROW_JSON) json/from_string.cc json/json_writer_internal.cc json/object_parser.cc - json/json_writer.cc json/parser.cc json/reader.cc) foreach(ARROW_JSON_TARGET ${ARROW_JSON_TARGETS}) diff --git a/cpp/src/arrow/json/json_writer_internal.cc b/cpp/src/arrow/json/json_writer_internal.cc index 11fe70a7415e..49038f26b073 100644 --- a/cpp/src/arrow/json/json_writer_internal.cc +++ b/cpp/src/arrow/json/json_writer_internal.cc @@ -115,4 +115,14 @@ void JsonWriter::MaybeComma() { } } +void JsonWriter::StringField(std::string_view key, std::string_view value) { + Key(key); + String(value); +} + +void JsonWriter::BoolField(std::string_view key, bool value) { + Key(key); + Bool(value); +} + } // namespace arrow::json diff --git a/cpp/src/arrow/json/json_writer_internal.h b/cpp/src/arrow/json/json_writer_internal.h index e4d6e49885f8..0cdfaf49facf 100644 --- a/cpp/src/arrow/json/json_writer_internal.h +++ b/cpp/src/arrow/json/json_writer_internal.h @@ -56,6 +56,10 @@ class ARROW_EXPORT JsonWriter { void Clear(); + void StringField(std::string_view key, std::string_view value); + + void BoolField(std::string_view key, bool value); + private: void MaybeComma(); diff --git a/cpp/src/parquet/encryption/file_system_key_material_store.cc b/cpp/src/parquet/encryption/file_system_key_material_store.cc index a8b1278b7ab4..e5b215a84609 100644 --- a/cpp/src/parquet/encryption/file_system_key_material_store.cc +++ b/cpp/src/parquet/encryption/file_system_key_material_store.cc @@ -84,8 +84,7 @@ std::string FileSystemKeyMaterialStore::BuildKeyMaterialMapJson() { ::arrow::json::JsonWriter writer; writer.StartObject(); for (const auto& it : key_material_map_) { - writer.Key(it.first); - writer.String(it.second); + writer.StringField(it.first, it.second); } writer.EndObject(); return std::string(writer.GetString()); diff --git a/cpp/src/parquet/encryption/key_material.cc b/cpp/src/parquet/encryption/key_material.cc index 76f011e7adc7..67f838c1df1b 100644 --- a/cpp/src/parquet/encryption/key_material.cc +++ b/cpp/src/parquet/encryption/key_material.cc @@ -22,8 +22,8 @@ #include "parquet/encryption/key_metadata.h" #include "parquet/exception.h" -using ::arrow::json::internal::ObjectParser; using ::arrow::json::JsonWriter; +using ::arrow::json::internal::ObjectParser; namespace parquet::encryption { @@ -126,52 +126,43 @@ std::string KeyMaterial::SerializeToJson( json_writer.StartObject(); - json_writer.Key(kKeyMaterialTypeField); - json_writer.String(kKeyMaterialType1); + json_writer.StringField(kKeyMaterialTypeField, kKeyMaterialType1); if (is_internal_storage) { - json_writer.Key(KeyMetadata::kKeyMaterialInternalStorageField); - json_writer.Bool(true); + // 1. for internal storage, key material and key metadata are the same. + // adding the "internalStorage" field that belongs to KeyMetadata. + json_writer.BoolField(KeyMetadata::kKeyMaterialInternalStorageField, true); } // 2. Write isFooterKey - json_writer.Key(kIsFooterKeyField); - json_writer.Bool(is_footer_key); + json_writer.BoolField(kIsFooterKeyField, is_footer_key); if (is_footer_key) { // 3. For footer key, write KMS Instance ID - json_writer.Key(kKmsInstanceIdField); - json_writer.String(kms_instance_id); + json_writer.StringField(kKmsInstanceIdField, kms_instance_id); // 4. For footer key, write KMS Instance URL - json_writer.Key(kKmsInstanceUrlField); - json_writer.String(kms_instance_url); + json_writer.StringField(kKmsInstanceUrlField, kms_instance_url); } // 5. Write master key ID - json_writer.Key(kMasterKeyIdField); - json_writer.String(master_key_id); + json_writer.StringField(kMasterKeyIdField, master_key_id); // 6. Write wrapped DEK - json_writer.Key(kWrappedDataEncryptionKeyField); - json_writer.String(encoded_wrapped_dek); + json_writer.StringField(kWrappedDataEncryptionKeyField, encoded_wrapped_dek); // 7. Write isDoubleWrapped - json_writer.Key(kDoubleWrappingField); - json_writer.Bool(is_double_wrapped); + json_writer.BoolField(kDoubleWrappingField, is_double_wrapped); if (is_double_wrapped) { // 8. In double wrapping mode, write KEK ID - json_writer.Key(kKeyEncryptionKeyIdField); - json_writer.String(kek_id); + json_writer.StringField(kKeyEncryptionKeyIdField, kek_id); // 9. In double wrapping mode, write wrapped KEK - json_writer.Key(kWrappedKeyEncryptionKeyField); - json_writer.String(encoded_wrapped_kek); + json_writer.StringField(kWrappedKeyEncryptionKeyField, encoded_wrapped_kek); } json_writer.EndObject(); - return std::string(json_writer.GetString()); } diff --git a/cpp/src/parquet/encryption/key_metadata.cc b/cpp/src/parquet/encryption/key_metadata.cc index fdd52aafd118..ed6c62955cf2 100644 --- a/cpp/src/parquet/encryption/key_metadata.cc +++ b/cpp/src/parquet/encryption/key_metadata.cc @@ -21,8 +21,8 @@ #include "parquet/encryption/key_metadata.h" #include "parquet/exception.h" -using ::arrow::json::internal::ObjectParser; using ::arrow::json::JsonWriter; +using ::arrow::json::internal::ObjectParser; namespace parquet::encryption { @@ -77,14 +77,10 @@ std::string KeyMetadata::CreateSerializedForExternalMaterial( json_writer.StartObject(); - json_writer.Key(KeyMaterial::kKeyMaterialTypeField); - json_writer.String(KeyMaterial::kKeyMaterialType1); - - json_writer.Key(kKeyMaterialInternalStorageField); - json_writer.Bool(false); - - json_writer.Key(kKeyReferenceField); - json_writer.String(key_reference); + json_writer.StringField(KeyMaterial::kKeyMaterialTypeField, + KeyMaterial::kKeyMaterialType1); + json_writer.BoolField(kKeyMaterialInternalStorageField, false); + json_writer.StringField(kKeyReferenceField, key_reference); json_writer.EndObject(); diff --git a/cpp/src/parquet/encryption/local_wrap_kms_client.cc b/cpp/src/parquet/encryption/local_wrap_kms_client.cc index 10c7928c9d76..b2a6872af5bd 100644 --- a/cpp/src/parquet/encryption/local_wrap_kms_client.cc +++ b/cpp/src/parquet/encryption/local_wrap_kms_client.cc @@ -23,8 +23,8 @@ #include "parquet/encryption/local_wrap_kms_client.h" #include "parquet/exception.h" -using ::arrow::json::internal::ObjectParser; using ::arrow::json::JsonWriter; +using ::arrow::json::internal::ObjectParser; using ::arrow::util::SecureString; namespace parquet::encryption { @@ -45,11 +45,8 @@ std::string LocalWrapKmsClient::LocalKeyWrap::CreateSerialized( json_writer.StartObject(); - json_writer.Key(kLocalWrapKeyVersionField); - json_writer.String(kLocalWrapNoKeyVersion); - - json_writer.Key(kLocalWrapEncryptedKeyField); - json_writer.String(encrypted_encoded_key); + json_writer.StringField(kLocalWrapKeyVersionField, kLocalWrapNoKeyVersion); + json_writer.StringField(kLocalWrapEncryptedKeyField, encrypted_encoded_key); json_writer.EndObject(); From 74e39decdbcbdcb8225b30a2887873341f21f820 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Wed, 29 Jul 2026 10:34:19 +0200 Subject: [PATCH 4/4] Nit: regroup method declarations --- cpp/src/arrow/json/json_writer_internal.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cpp/src/arrow/json/json_writer_internal.h b/cpp/src/arrow/json/json_writer_internal.h index 0cdfaf49facf..4173cb4c512c 100644 --- a/cpp/src/arrow/json/json_writer_internal.h +++ b/cpp/src/arrow/json/json_writer_internal.h @@ -52,14 +52,13 @@ class ARROW_EXPORT JsonWriter { void Null(); + void StringField(std::string_view key, std::string_view value); + void BoolField(std::string_view key, bool value); + std::string_view GetString() const; void Clear(); - void StringField(std::string_view key, std::string_view value); - - void BoolField(std::string_view key, bool value); - private: void MaybeComma();