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

Clean up implementation of binary type #2125

Merged
merged 16 commits into from May 20, 2020
Merged

Clean up implementation of binary type #2125

merged 16 commits into from May 20, 2020

Conversation

nlohmann
Copy link
Owner

@nlohmann nlohmann commented May 19, 2020

This PR polishes the integration of the binary type introduced in #1662 .

Changes:

  • Added example to README.
  • Extended examples for type checking functions like is_array, etc.
  • Added a swap function.
  • Created separate header file for byte_container_with_subtype. binary_t is an alias to this and replaces the previous internal_binary_t. There is no alias for the BinaryType template parameter any more - if needed, it is binary_t::container_type.
  • Added conversions between JSON and binary type.
  • Changed JSON serialization of binary types to object with bytes array and subtype integer/null value, e.g. {"bytes": [1,2,3], "subtype": 10}. Serialization to JSON is only for debugging purposes and should always produce valid JSON.
  • Added test cases to achieve 100% coverage.
  • Added get_binary function for simple access to the binary value by (const) reference.
  • Rename json::binary_array to binary for symmetry to json::object and json::array constructors.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 100.0% when pulling 4d39644 on binary_type into 5cfa8a5 on develop.

@OmnipotentEntity
Copy link
Contributor

Looks good to me. Thanks so much for cleaning this up.

@nlohmann
Copy link
Owner Author

Looks good to me. Thanks so much for cleaning this up.

Thank you for implementing the feature in the first place!

@nlohmann nlohmann merged commit a82c80e into develop May 20, 2020
@nlohmann nlohmann deleted the binary_type branch May 20, 2020 16:58
@nlohmann nlohmann restored the binary_type branch May 20, 2020 16:58
@nlohmann nlohmann deleted the binary_type branch May 20, 2020 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants