2 # ==================================================================================
3 # Copyright (c) 2020 HCL Technologies Limited.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 # ==================================================================================
18 #include"XAppConfig.h"
21 void from_json(const nlohmann::json& j, XAppConfig& ref) {
22 std::cout << __PRETTY_FUNCTION__ << std::endl;
24 j.at("metadata").get_to(ref.m_ConfigMetadata);
25 j.at("config").get_to(ref.config);
28 void from_json(const nlohmann::json& j, std::vector<XAppConfig>& ref) {
29 for (auto& element : j) {
31 tmp.validate_json(element);
32 for (auto& val : element.items())
34 if (val.key() == "metadata") {
35 tmp.m_ConfigMetadata.ConfigType = val.value()["configType"];
36 tmp.m_ConfigMetadata.XappName = val.value()["xappName"];
38 else if (val.key() == "config") {
39 tmp.config = val.value();
46 void to_json(nlohmann::json& j, const XAppConfig& ref) {
48 {"metadata",{{"configType",ref.m_ConfigMetadata.ConfigType},{"xappName",ref.m_ConfigMetadata.XappName}}},
53 void to_json(nlohmann::json& j, const std::vector<XAppConfig>& ref) {
54 for (int i = 0; i < ref.size(); i++)
57 to_json(tmp_j, ref[i]);