Skip to content

Commit

Permalink
surely THIS time
Browse files Browse the repository at this point in the history
  • Loading branch information
Mishura4 committed Oct 6, 2023
1 parent f768e93 commit 9bbdf5f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/dpp/discordevents.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void DPP_EXPORT set_snowflake_array_not_null(const nlohmann::json* j, const char
* @param key key name to check for the values
* @param fn function to apply to each element
*/
void DPP_EXPORT for_each_json(nlohmann::json* parent, std::string_view key, std::function<void(const nlohmann::json*)> fn);
void DPP_EXPORT for_each_json(nlohmann::json* parent, std::string_view key, const std::function<void(nlohmann::json*)> &fn);

/** @brief Sets an array of objects from a json field value, if defined, else does nothing
* @tparam T The class of which the array consists of. Must be derived from dpp::json_interface
Expand Down
4 changes: 2 additions & 2 deletions src/dpp/discordevents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ void set_snowflake_array_not_null(const json* j, const char *keyname, std::vecto
}
}

void for_each_json(const nlohmann::json* parent, const char* key, std::function<void(const nlohmann::json*)> fn) {
void for_each_json(nlohmann::json* parent, std::string_view key, const std::function<void(nlohmann::json*)> &fn) {
auto it = parent->find(key);
if (it == parent->end() || it->is_null()) {
return;
}
for (const nlohmann::json &elem : *parent) {
for (nlohmann::json &elem : *parent) {
fn(&elem);
}
}
Expand Down

0 comments on commit 9bbdf5f

Please sign in to comment.