OXY API 1.0
OXY API Library Documentation
Loading...
Searching...
No Matches
json_helper.hpp File Reference

JSON helper functions for the oxy core library. More...

Classes

struct  oxy::push_optional_f
 Functor to push an optional value into a JSON object. More...
struct  oxy::set_value_f
 Functor to set a value in a JSON object. More...

Namespaces

namespace  oxy
 This root namespace contains the common types and operations for the OXY-API library.

Functions

template<typename T>
auto oxy::dumps (T const &item) -> std::string
 Helper function to serialize an object of type T to a JSON string.
template<typename T>
auto oxy::get_object (json::value const &jv, json::string_view key)
 Helper function to get a value of type T from a JSON object by key.
template<typename T>
auto oxy::get_value (json::value const &jv, json::string_view key) -> std::optional< T >
 Helper function to get a value of type T from a JSON object by key.
template<typename T>
auto oxy::loads (std::string const &stream) -> T
 Helper function to deserialize a JSON string to an object of type T.
void oxy::merge_json (boost::json::value &dst, const boost::json::value &src, bool array_append=false)
 Helper function to merge two JSON values recursively.
template<typename T>
auto & oxy::to_object (T &value, json::value const &jv, json::string_view key)
 Helper function to set a value of type T in a JSON object by key.

Variables

template<typename T>
constexpr auto oxy::push_optional = hof::pipable(push_optional_f{})
 A pipable adaptor for the push_optional_f functor, allowing for functional programming style.
template<typename T>
constexpr auto oxy::set_value = hof::pipable(set_value_f{})
 A pipable adaptor for the set_value_f functor, allowing for functional programming style.

Detailed Description

JSON helper functions for the oxy core library.

This header defines helper functions for working with JSON values using the Boost.JSON library. It includes functions to set values, push optional values, get values, and merge JSON objects. The functions are designed to be used in a functional programming style with pipable adaptors. The merge_json function allows for recursive merging of JSON objects and arrays with customizable behavior for array merging. The helper functions are intended to simplify facilitate working with JSON data in the oxy library.

@license MPL-2.0