12 #include <nlohmann/json.hpp>
16 template<
class Jsonish,
class Key,
class Func>
20 && std::invoke(std::forward<Func>(f), std::forward<Jsonish>(j)[std::forward<Key>(k)]);
28 || (j.is_number_integer()
29 && j.template get<long long>() <= 9007199254740991LL
30 && j.template get<long long>() >= -9007199254740991LL)
35 template<
class Jsonish,
class RangeT>
36 std::optional<std::decay_t<Jsonish>>
getInJson(Jsonish &&j,
RangeT &&path, std::size_t index = 0)
38 if (index >= path.size()) {
39 return std::forward<Jsonish>(j);
42 auto currentSegment = path[index];
43 if (j.is_object() && j.contains(currentSegment)) {
44 return getInJson(std::forward<Jsonish>(j)[currentSegment], std::forward<RangeT>(path), index + 1);
A RangeT is an ordered collection that can be iterated through.
Definition: range-t.hpp:21
Definition: location.hpp:10
bool hasAtThat(Jsonish &&j, Key &&k, Func &&f)
Definition: json-utils.hpp:17
nlohmann::json json
Definition: jsonwrap.hpp:20
bool isNonCompoundCanonicalJsonValue(const nlohmann::json &j)
Definition: json-utils.hpp:25
std::optional< std::decay_t< Jsonish > > getInJson(Jsonish &&j, RangeT &&path, std::size_t index=0)
Definition: json-utils.hpp:36