Skip to content

from_*(ptr, len) deprecation #2426

Closed
Closed

Description

@lrasinen

From 3.9.1 release notes:

Passing iterator pairs or pointer/length pairs to parsing functions (basic_json::parse, basic_json::accept, basic_json::sax_parse, basic_json::from_cbor, basic_json::from_msgpack, basic_json::from_ubjson, basic_json::from_bson) via initializer lists is deprecated. Instead, pass the elements individually without braces.

However, the pointer/length overload is marked as deprecated at least for the from_* functions:

    JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len))
    JSON_HEDLEY_WARN_UNUSED_RESULT
    static basic_json from_cbor(const T* ptr, std::size_t len, ...

Is this an error in the release notes or is the deprecation in error?

Activity

  1. nlohmann commented on Oct 8, 2020

    @nlohmann
    Owner

    You mean the version number?

  2. lrasinen commented on Oct 8, 2020

    @lrasinen
    Author

    My understanding of the release note wording is that e.g. from_cbor({ptr, len}) is deprecated, but that from_cbor(ptr, len) is the recommended alternative. But the second form is also deprecated.

  3. gregmarr commented on Oct 8, 2020

    @gregmarr
    Contributor

    The recommended alternative is not from_cbor(ptr, len) but from_cbor(ptr, ptr + len, ...).

  4. gregmarr commented on Oct 8, 2020

    @gregmarr
    Contributor

    @nlohmann Probably good to update the deprecation notice to include that one as well, as it's not really covered by the current note.

  5. lrasinen commented on Oct 8, 2020

    @lrasinen
    Author

    Agreed. My experience with this was something like this:

    • I got some binary data in ptr/len format
    • Went looking at the API whether that's supported directly
    • Found Doxygen docs, which do not show the deprecation status
    • Was baffled at compile warning
    • Went looking at the release notes which were unclear

    I can (and do) use the ptr/ptr+len overload instead (although the ptr/len combo is quite convenient when applicable).

  6. stale commented on Dec 25, 2020

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

  7. added
    state: stalethe issue has not been updated in a while and will be closed automatically soon unless it is updated
    on Dec 25, 2020
  8. added and removed
    state: stalethe issue has not been updated in a while and will be closed automatically soon unless it is updated
    on Dec 26, 2020
  9. nlohmann commented on Dec 28, 2020

    @nlohmann
    Owner

    Sorry for not reacting earlier. In order to clean the API after a lot of experimenting with how to cope with different input types, we decided that the overload that takes two iterators is the one we would like to proceed with.

    The release notes are indeed misleading. They should read:

    This release deprecates passing iterator pairs or pointer/length pairs to parsing functions (basic_json::parse, basic_json::accept, basic_json::sax_parse, basic_json::from_cbor, basic_json::from_msgpack, basic_json::from_ubjson, basic_json::from_bson) via initializer lists. Instead, pass two iterators; for instance, call basic_json::from_cbor(ptr, ptr+len) instead of basic_json::from_cbor({ptr, len}).

    @lrasinen @gregmarr Do you agree with the new wording of the last sentence?

  10. lrasinen commented on Dec 28, 2020

    @lrasinen
    Author

    I'm quite happy with suggested wording, thanks.

  11. self-assigned this
    on Dec 29, 2020
  12. nlohmann commented on Dec 29, 2020

    @nlohmann
    Owner

    I adjusted the release notes of version 3.8.0, 3.9.0, and 3.9.1.

  13. gregmarr commented on Jan 4, 2021

    @gregmarr
    Contributor

    LGTM

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

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions