eProsima / Fast-DDS-Gen

Fast-DDS IDL code generator tool. Looking for commercial support? Contact info@eprosima.com
Apache License 2.0
80 stars 59 forks source link

Feature/json #204

Closed mikegratton closed 1 year ago

mikegratton commented 1 year ago

Add to/from json support.

For type-to-json, I've added a method to generated types toJson() that produces a json string. This requires the changes to the idl parser to distinguish enum types (so that they may be serialized as strings in json). These json strings provide a simple way to view the contents of an idl-derived type when debugging an application.

For type-from-json, I added optional extra output files.

I know requiring users of fastddsgen to supply libraries other than fastcdr is a burden, so I've tried to isolate use by making these files (a) optionally generated and (b) only requiring the library for the cxx.

JLBuenoLopez commented 1 year ago

Thanks for your contribution @mikegratton

Fast DDS developers have internally discussed this feature and the agreement is that this feature is not going to be officially supported in Fast DDS-Gen. Having features contributed by the community but without an official maintenance is risky and might arise false expectations in the Fast DDS-Gen users. Besides, the custom templates feature, -extrastg, recently included in Fast DDS-Gen might be used to generate the JSON files you are interested in. This feature is scarcely documented and efforts to improve it will be made.

Consequently, I am going to proceed and close this PR. Thanks for your understanding!