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 · 1 comment

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

@Artem-OSSRevival
Copy link

Artem-OSSRevival commented Feb 18, 2025

Hi, I’m Artem from OSS Revival. We specialize in revitalizing and maintaining open-source projects for long-term stability. After some research, we found that this Issue is not valid. The equality operators described above are not used while at() function calling, and are correctly marked as deprecated. A warning arises due to the Clang-tidy checks the entire file code, not just what is really used.
To make sure of this, it is enough to remove/comment these templates from the code, and execute the program. The result will be the same.

Artem-OSSRevival pushed a commit to Project-OSS-Revival/json that referenced this issue Feb 18, 2025
Artem-OSSRevival added a commit to Project-OSS-Revival/json that referenced this issue Feb 18, 2025
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

2 participants