Represents an interface for an object that can optionally implement functions for converting to and from nlohmann::json. More...
#include "json_interface.h"
Inherited by dpp::automod_action, dpp::channel, dpp::component, dpp::emoji, dpp::interaction_modal_response, dpp::scheduled_event, dpp::thread, dpp::voicestate, and dpp::welcome_channel.
Public Member Functions | |
template<typename U = T, typename = decltype(std::declval<U&>().to_json_impl(bool{}))> | |
std::string | build_json (bool with_id=false) const |
Convert object to json string. More... | |
template<typename U = T, typename = decltype(std::declval<U&>().fill_from_json_impl(std::declval<nlohmann::json*>()))> | |
T & | fill_from_json (nlohmann::json *j) |
Convert object from nlohmann::json. More... | |
template<typename U = T, typename = decltype(std::declval<U&>().to_json_impl(bool{}))> | |
auto | to_json (bool with_id=false) const |
Convert object to nlohmann::json. More... | |
Represents an interface for an object that can optionally implement functions for converting to and from nlohmann::json.
The methods are only present if the actual object also has those methods.
T | Type of class that implements the interface |
|
inline |
Convert object to json string.
with_id | Whether to include the ID or not |
Referenced by dpp::cluster::create_webhook(), dpp::cluster::guild_ban_add(), dpp::cluster::guild_ban_delete(), dpp::cluster::guild_command_edit_permissions(), dpp::cluster::guild_create(), dpp::cluster::guild_get_integrations(), dpp::cluster::guild_get_preview(), dpp::cluster::guild_get_vanity(), and dpp::cluster::roles_get().
|
inline |
Convert object from nlohmann::json.
j | nlohmann::json object |
Referenced by dpp::invite::fill_from_json_impl(), dpp::thread::fill_from_json_impl(), dpp::scheduled_event::fill_from_json_impl(), dpp::from_json(), dpp::message::get_url(), and dpp::interaction_response::interaction_response().
|
inline |
Convert object to nlohmann::json.
with_id | Whether to include the ID or not |
Referenced by dpp::cluster::delete_webhook_with_token(), and dpp::onboarding_prompt::onboarding_prompt().