David Valleau | 4822bac | 2018-12-12 10:33:51 -0800 | [diff] [blame] | 1 | // Copyright 2018 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Fletcher Woodruff | 6cdda0a | 2020-04-22 11:14:07 -0600 | [diff] [blame] | 5 | #ifndef VALUE_UTIL_H__ |
| 6 | #define VALUE_UTIL_H__ |
David Valleau | 4822bac | 2018-12-12 10:33:51 -0800 | [diff] [blame] | 7 | |
Fletcher Woodruff | 76e9e78 | 2020-04-30 16:51:26 -0600 | [diff] [blame] | 8 | #include <memory> |
| 9 | #include <string> |
| 10 | |
David Valleau | 4822bac | 2018-12-12 10:33:51 -0800 | [diff] [blame] | 11 | #include <base/json/json_reader.h> |
| 12 | #include <base/optional.h> |
| 13 | #include <base/values.h> |
| 14 | |
David Valleau | 4822bac | 2018-12-12 10:33:51 -0800 | [diff] [blame] | 15 | // Attempt to load the contents of the JSON file located at |file_path| and |
| 16 | // return the contents in a string. |
| 17 | base::Optional<std::string> GetJSONContents(const std::string& file_path); |
| 18 | |
| 19 | // Use a JSONReader to parse |json_contents| and return a pointer to the |
| 20 | // underlying Value object. |
hscham | 0ba2897 | 2020-11-09 11:19:02 +0900 | [diff] [blame] | 21 | base::Optional<base::Value> GetJSONValue(const std::string& json_contents); |
David Valleau | 4822bac | 2018-12-12 10:33:51 -0800 | [diff] [blame] | 22 | |
Fletcher Woodruff | 6cdda0a | 2020-04-22 11:14:07 -0600 | [diff] [blame] | 23 | #endif // VALUE_UTIL_H__ |