1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef DEVELOPTOOLS_PACKING_TOOL_APT_FRAMEWORKS_INCLUDE_JSON_UTILS_H 17 #define DEVELOPTOOLS_PACKING_TOOL_APT_FRAMEWORKS_INCLUDE_JSON_UTILS_H 18 19 #include <memory> 20 #include <string> 21 22 #include "pt_json.h" 23 24 namespace OHOS { 25 namespace AppPackingTool { 26 class JsonUtils { 27 public: JsonUtils()28 JsonUtils() {}; ~JsonUtils()29 virtual ~JsonUtils() {}; 30 31 JsonUtils(const JsonUtils &) = delete; 32 JsonUtils &operator=(const JsonUtils &) = delete; 33 34 static bool IsModuleJson(const std::string& filePath); 35 static bool IsConfigJson(const std::string& filePath); 36 static bool IsPatchJson(const std::string& filePath); 37 38 static std::unique_ptr<PtJson> JsonFromFile(const std::string& filePath); 39 static bool JsonToFile(const std::unique_ptr<PtJson>& json, const std::string& filePath); 40 static bool StrToFile(const std::string& str, const std::string& filePath); 41 }; 42 } // namespace AppPackingTool 43 } // namespace OHOS 44 #endif // DEVELOPTOOLS_PACKING_TOOL_APT_FRAMEWORKS_INCLUDE_JSON_UTILS_H 45