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

[20903] DynamicData to JSON serializer #4780

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

juanlofer-eprosima
Copy link
Contributor

Description

This PR introduces a couple of utility functions meant to ease the transformation of a DynamicData to a digestible JSON object, which is dumped either to a user-provided output string or ostream. The resulting JSON objects can follow the OMG standard format (as in https://www.omg.org/spec/DDS-JSON/1.0/Beta1/PDF), or an alternative custom one.

Tests remain to be implemented.

Contributor Checklist

  • Commit messages follow the project guidelines.
  • The code follows the style guidelines of this project.
  • Tests that thoroughly check the new feature have been added/Regression tests checking the bug and its fix have been added; the added tests pass locally
  • Any new/modified methods have been properly documented using Doxygen.
  • N/A Any new configuration API has an equivalent XML API (with the corresponding XSD extension)
  • Changes are ABI compatible.
  • Changes are API compatible.
  • New feature has been added to the versions.md file (if applicable).
  • New feature has been documented/Current behavior is correctly described in the documentation.
  • N/A Applicable backports have been included in the description.

Reviewer Checklist

  • The PR has a milestone assigned.
  • The title and description correctly express the PR's purpose.
  • Check contributor checklist is correct.
  • Check CI results: changes do not issue any warning.
  • Check CI results: failing tests are unrelated with the changes.

Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>
Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>
@juanlofer-eprosima juanlofer-eprosima added this to the v3.0.0 milestone May 14, 2024
}
else
{
EPROSIMA_LOG_WARNING(XTYPES_UTILS, "Error encountered while performing DynamicData to JSON serialization.");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove redundant warning or modify content so it's specific for this overload.

Comment on lines +267 to +281
// Return loaned value
ReturnCode_t ret_return_loan;
if (RETCODE_OK != (ret_return_loan = data->return_loaned_value(st_data)))
{
EPROSIMA_LOG_WARNING(XTYPES_UTILS, "Error encountered while returning loaned value.");
}
// Give priority to prior error if occurred
if (RETCODE_OK != ret)
{
return ret;
}
else
{
return ret_return_loan;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any nicer way of doing this?


return json_serialize_member(data, type_member->get_id(),
traits<DynamicType>::narrow<DynamicTypeImpl>(
member_desc.type())->resolve_alias_enclosed_type()->get_kind(),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extend DynamicTypeImpl to have a new attribute + getter for its enclosing type, so the recursive search is only done once.

@juanlofer-eprosima
Copy link
Contributor Author

Bitset inheritance has recently refactored, I would add coverage for this scenario.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-review PR that is ready to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants