Function rcl_type_description_to_hashable_json

Function Documentation

rcl_ret_t rcl_type_description_to_hashable_json(const type_description_interfaces__msg__TypeDescription *type_description, rcutils_char_array_t *output_repr)

Given a TypeDescription, output a string of the hashable JSON representation of that data.

The output here is generally hashed via rcl_calculate_type_hash() below. Compare this reference implementation with the .json output files from rosidl_generator_type_description.generate_type_hash. Both must produce the same output for the same types, providing a stable reference for external implementations of the ROS 2 Type Version Hash.

The JSON representation contains all types and fields of the original message, but excludes:

  • Default values

  • Comments

  • The input plaintext files that generated the TypeDescription

Parameters:
  • type_description[in] Prefilled TypeDescription message to be translated

  • output_repr[out] An initialized empty char array that will be filled with the JSON representation of type_description. Note that output_repr will have a terminating null character, which should be omitted from hashing. To do so, use (output_repr.buffer_length - 1) or strlen(output_repr.buffer) for the size of data to hash.

Returns:

RCL_RET_OK on success, or

Returns:

RCL_RET_ERROR if any problems occur in translation.