Skip to content

Commit 9a524da

Browse files
JSON to DynamicData deserializer (#5553)
* Refs #22202. Add support for ROS 2 types Signed-off-by: Juan Lopez Fernandez <[email protected]> * Refs #22202. Support all types Signed-off-by: Juan Lopez Fernandez <[email protected]> * Refs #22202. Add tests Signed-off-by: Juan Lopez Fernandez <[email protected]> * Refs #22202. Update versions.md Signed-off-by: Juan Lopez Fernandez <[email protected]> * Refs #22202. Add missing sources Signed-off-by: Juan Lopez Fernandez <[email protected]> * Refs #22202. Remove Windows warnings Signed-off-by: Juan Lopez Fernandez <[email protected]> * Refs #22202. Encapsulate complex methods Signed-off-by: Juan Lopez Fernandez <[email protected]> * Refs #22202. Uncrustify Signed-off-by: Juan Lopez Fernandez <[email protected]> * Refs #22202. Fix null-dereference error Signed-off-by: Juan Lopez Fernandez <[email protected]> * Refs #22202. Apply suggestions Signed-off-by: Juan Lopez Fernandez <[email protected]> * Refs #22202. Fix Windows deadlock in tests closure Signed-off-by: Juan Lopez Fernandez <[email protected]> --------- Signed-off-by: Juan Lopez Fernandez <[email protected]>
1 parent 6ec2a97 commit 9a524da

18 files changed

+2851
-652
lines changed

include/fastdds/dds/xtypes/utils.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,20 @@ FASTDDS_EXPORTED_API ReturnCode_t json_serialize(
6060
DynamicDataJsonFormat format,
6161
std::ostream& output) noexcept;
6262

63+
/*!
64+
* Deserializes a JSON object string into a @ref DynamicData.
65+
* @param[in] input JSON object string to be deserialized.
66+
* @param[in] dynamic_type @ref DynamicType corresponding to the @ref DynamicData where the JSON string is deserialized.
67+
* @param[in] format @ref DynamicDataJsonFormat JSON serialization format.
68+
* @param[in,out] data @ref DynamicData reference where the JSON string is deserialized. Must be null.
69+
* @retval RETCODE_OK when deserialization fully succeeds, RETCODE_BAD_PARAMETER when parsing fails or preconditions are not met, and inner (member deserialization) failing code otherwise.
70+
*/
71+
FASTDDS_EXPORTED_API ReturnCode_t json_deserialize(
72+
const std::string& input,
73+
const DynamicType::_ref_type& dynamic_type,
74+
DynamicDataJsonFormat format,
75+
DynamicData::_ref_type& data) noexcept;
76+
6377
} // dds
6478
} // fastdds
6579
} // eprosima

src/cpp/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ set(${PROJECT_NAME}_source_files
112112
fastdds/xtypes/exception/Exception.cpp
113113
fastdds/xtypes/serializers/idl/dynamic_type_idl.cpp
114114
fastdds/xtypes/serializers/json/dynamic_data_json.cpp
115+
fastdds/xtypes/serializers/json/json_dynamic_data.cpp
115116
fastdds/xtypes/type_representation/dds_xtypes_typeobjectPubSubTypes.cxx
116117
fastdds/xtypes/type_representation/TypeObjectRegistry.cpp
117118
fastdds/xtypes/type_representation/TypeObjectUtils.cpp

src/cpp/fastdds/xtypes/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ target_sources(fastdds-xtypes-dynamic-types-impl INTERFACE
8282
serializers/idl/dynamic_type_idl.hpp
8383
serializers/json/dynamic_data_json.cpp
8484
serializers/json/dynamic_data_json.hpp
85+
serializers/json/json_dynamic_data.cpp
86+
serializers/json/json_dynamic_data.hpp
8587
utils.cpp
8688
)
8789

0 commit comments

Comments
 (0)