OXY API 1.0
OXY API Library Documentation
Loading...
Searching...
No Matches
oxy::set_value_f Struct Reference

Functor to set a value in a JSON object. More...

#include <json_helper.hpp>

Public Member Functions

template<class T>
json::value & operator() (json::value &jv, json::string_view key, T const &item) const

Detailed Description

Functor to set a value in a JSON object.

This functor provides an operator() that takes a JSON value, a key, and an item of a generic type T. It checks if the JSON value is an object, and if not, it emplaces an empty object. It then inserts or assigns the key-value pair in the JSON object, where the value is obtained by converting the item to a JSON value using json::value_from. The functor returns a reference to the modified JSON value, allowing for chaining of operations.

Member Function Documentation

◆ operator()()

template<class T>
json::value & oxy::set_value_f::operator() ( json::value & jv,
json::string_view key,
T const & item ) const
inline
Template Parameters
T- The type of the item to be set in the JSON object.
Parameters
jv- The JSON value to modify.
key- The key to set in the JSON object.
item- The item to set in the JSON object.
Returns
A reference to the modified JSON value.