Skip to content

nlohman::ordered_json using deprecated operators on calls to .value and .at with join_pointers #4621

@jllansford

Description

@jllansford

Description

When using the .at or .value functions on a ordered_json object with a parameter type of json_pointer there is a deprecation warning due to the following functions being called:

template<typename RefStringTypeLhs, typename StringType = typename json_pointer<RefStringTypeLhs>::string_t>
JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator==(json_pointer, json_pointer)) 
inline bool operator==(const json_pointer<RefStringTypeLhs>& lhs, const StringType& rhs)
{
    return lhs == json_pointer<RefStringTypeLhs>(rhs);
}

template<typename RefStringTypeRhs, typename StringType = typename json_pointer<RefStringTypeRhs>::string_t>
JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator==(json_pointer, json_pointer)) 
inline bool operator==(const StringType& lhs, const json_pointer<RefStringTypeRhs>& rhs)
{
    return json_pointer<RefStringTypeRhs>(lhs) == rhs;
}

Reproduction steps

The sample code should illustrate the problem.

Expected vs. actual results

.at and .value should ideally not depend on deprecated functions unless they themselves are deprecated.

Minimal code example

using json = nlohmann::ordered_json;
using json_pointer = json::json_pointer;

int main() {
    json j = {{"key", "value"}};
    json_pointer ptr("/key");

    auto value = j.at(ptr); //deprecation warning
    return 0;
}

Error messages

warning: 'operator==' is deprecated: Since 3.11.2; use operator==(json_pointer, json_pointer) [-Wdeprecated-declarations]

...

while substituting deduced template arguments into function template 'at' [with KeyType = json_pointer &, $1 = (no value)]

Compiler and operating system

gcc & clang

Library version

3.11.3

Validation

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions