Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 of 2 tasks
jllansford opened this issue Jan 23, 2025 · 0 comments

Comments

@jllansford
Copy link

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::string_t>
JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator==(json_pointer, json_pointer))
inline bool operator==(const json_pointer& lhs, const StringType& rhs)
{
return lhs == json_pointer(rhs);
}

template<typename RefStringTypeRhs, typename StringType = typename json_pointer::string_t>
JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator==(json_pointer, json_pointer))
inline bool operator==(const StringType& lhs, const json_pointer& rhs)
{
return json_pointer(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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant