wgtmac commented on code in PR #251: URL: https://github.com/apache/iceberg-cpp/pull/251#discussion_r2450273503
########## src/iceberg/catalog/rest/json_internal.h: ########## @@ -0,0 +1,190 @@ +/* + * 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 <nlohmann/json_fwd.hpp> + +#include "iceberg/catalog/rest/types.h" +#include "iceberg/result.h" + +namespace iceberg::rest { + +/// \brief Serializes a `ListNamespaceResponse` object to JSON. +/// +/// \param response The `ListNamespaceResponse` object to be serialized. +/// \return A JSON object representing the `ListNamespaceResponse`. +nlohmann::json ToJson(const ListNamespaceResponse& response); + +/// \brief Deserializes a JSON object into a `ListNamespaceResponse` object. +/// +/// \param json The JSON object representing a `ListNamespaceResponse`. +/// \return A `ListNamespaceResponse` object or an error if the conversion fails. +Result<ListNamespaceResponse> ListNamespaceResponseFromJson(const nlohmann::json& json); + +/// \brief Serializes a `CreateNamespaceRequest` object to JSON. +/// +/// \param request The `CreateNamespaceRequest` object to be serialized. +/// \return A JSON object representing the `CreateNamespaceRequest`. +nlohmann::json ToJson(const CreateNamespaceRequest& request); + +/// \brief Deserializes a JSON object into a `CreateNamespaceRequest` object. +/// +/// \param json The JSON object representing a `CreateNamespaceRequest`. +/// \return A `CreateNamespaceRequest` object or an error if the conversion fails. +Result<CreateNamespaceRequest> CreateNamespaceRequestFromJson(const nlohmann::json& json); Review Comment: The signature of these `FromJson` functions is determined by how we will use request and response objects. If we use them without smart pointers, we can keep the current ones. If we use them with smart pointers, we need to follow `iceberg/json_internal.h` to return `Result<std::unique_ptr<X>` for them. I think the current ones are fine. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
