mirror of
https://github.com/OpenVPN/openvpn3.git
synced 2024-09-20 12:12:15 +02:00
jsonhelper: minor changes
* Added simple parse() method that only requires JSON string to be parsed. * Added get_string_from_array() method that doesn't require title parameter. * Added cast_array() method that doesn't require title parameter. Signed-off-by: James Yonan <james@openvpn.net>
This commit is contained in:
parent
550d308480
commit
819cc56962
@ -54,6 +54,11 @@ namespace openvpn {
|
||||
#endif
|
||||
}
|
||||
|
||||
inline Json::Value parse(const std::string& str)
|
||||
{
|
||||
return parse(str, "json");
|
||||
}
|
||||
|
||||
inline Json::Value parse_from_file(const std::string& fn)
|
||||
{
|
||||
return parse(read_text_utf8(fn), fn);
|
||||
@ -186,6 +191,12 @@ namespace openvpn {
|
||||
return value.asString();
|
||||
}
|
||||
|
||||
inline std::string get_string_from_array(const Json::Value& root,
|
||||
const Json::ArrayIndex index)
|
||||
{
|
||||
return get_string_from_array(root, index, nullptr);
|
||||
}
|
||||
|
||||
template <typename NAME, typename TITLE>
|
||||
inline int get_int(const Json::Value& root,
|
||||
const NAME& name,
|
||||
@ -534,6 +545,12 @@ namespace openvpn {
|
||||
return value;
|
||||
}
|
||||
|
||||
inline const Json::Value& cast_array(const Json::Value& value,
|
||||
const bool optional)
|
||||
{
|
||||
return cast_array(value, optional, nullptr);
|
||||
}
|
||||
|
||||
template <typename NAME, typename TITLE>
|
||||
inline void to_string(const Json::Value& root,
|
||||
std::string& dest,
|
||||
|
Loading…
Reference in New Issue
Block a user