36template <
typename KeyT,
typename... Paths>
37nlohmann::json safeGetMemberHelper(
const nlohmann::json& json, std::size_t index, Paths&&... otherPaths);
39inline nlohmann::json safeGetMemberHelper(
const nlohmann::json& json)
44template <
typename KeyT,
typename... Paths,
45 std::enable_if_t<!std::is_integral<std::remove_reference_t<KeyT>>::value>* =
nullptr>
46nlohmann::json safeGetMemberHelper(
const nlohmann::json& json, KeyT&& key, Paths&&... otherPaths)
48 auto memberIt = json.find(std::forward<KeyT>(key));
49 if (memberIt == json.end())
53 return safeGetMemberHelper(*memberIt, std::forward<Paths>(otherPaths)...);
57template <
typename... Paths>
58nlohmann::json safeGetMemberHelper(
const nlohmann::json& json, std::size_t index, Paths&&... otherPaths)
60 if (!json.is_array() || json.size() <= index)
64 return safeGetMemberHelper(json[index], std::forward<Paths>(otherPaths)...);
74bool validatePUTReply(
const std::string& path,
const nlohmann::json& request,
const nlohmann::json& reply);
83 return std::abs(lhs - rhs) <= 1E-4f;
91template <
typename... Paths>
92nlohmann::json
safeGetMember(
const nlohmann::json& json, Paths&&... paths)
94 return detail::safeGetMemberHelper(json, std::forward<Paths>(paths)...);
bool validatePUTReply(const std::string &path, const nlohmann::json &request, const nlohmann::json &reply)
Function for validating that a request was executed correctly.
Definition Utils.cpp:31