xref: /openbmc/phosphor-power/json_parser_utils.cpp (revision 38f8500414fe5c1be6f5159c563937289fe557c2)
1*38f85004SShawn McCarney /**
2*38f85004SShawn McCarney  * Copyright © 2025 IBM Corporation
3*38f85004SShawn McCarney  *
4*38f85004SShawn McCarney  * Licensed under the Apache License, Version 2.0 (the "License");
5*38f85004SShawn McCarney  * you may not use this file except in compliance with the License.
6*38f85004SShawn McCarney  * You may obtain a copy of the License at
7*38f85004SShawn McCarney  *
8*38f85004SShawn McCarney  *     http://www.apache.org/licenses/LICENSE-2.0
9*38f85004SShawn McCarney  *
10*38f85004SShawn McCarney  * Unless required by applicable law or agreed to in writing, software
11*38f85004SShawn McCarney  * distributed under the License is distributed on an "AS IS" BASIS,
12*38f85004SShawn McCarney  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*38f85004SShawn McCarney  * See the License for the specific language governing permissions and
14*38f85004SShawn McCarney  * limitations under the License.
15*38f85004SShawn McCarney  */
16*38f85004SShawn McCarney 
17*38f85004SShawn McCarney #include "json_parser_utils.hpp"
18*38f85004SShawn McCarney 
19*38f85004SShawn McCarney namespace phosphor::power::json_parser_utils
20*38f85004SShawn McCarney {
21*38f85004SShawn McCarney 
22*38f85004SShawn McCarney std::vector<uint8_t> parseHexByteArray(const nlohmann::json& element)
23*38f85004SShawn McCarney {
24*38f85004SShawn McCarney     verifyIsArray(element);
25*38f85004SShawn McCarney     std::vector<uint8_t> values;
26*38f85004SShawn McCarney     for (auto& valueElement : element)
27*38f85004SShawn McCarney     {
28*38f85004SShawn McCarney         values.emplace_back(parseHexByte(valueElement));
29*38f85004SShawn McCarney     }
30*38f85004SShawn McCarney     return values;
31*38f85004SShawn McCarney }
32*38f85004SShawn McCarney 
33*38f85004SShawn McCarney } // namespace phosphor::power::json_parser_utils
34