Skip to content

Latest commit

 

History

History
29 lines (16 loc) · 1.72 KB

File metadata and controls

29 lines (16 loc) · 1.72 KB

Reflection traits

Legacy jsoncons::json_type_traits

json_type_traits defines a compile time template based interface for conversion between a basic_json value and a value of some other type.

See Eigen::Matrix example for an example of specializing json_type_traits for an Eigen matrix class.

Note that in typical cases traits can be generated by the convenience macros described below.

jsoncons::reflect::json_conv_traits

jsoncons 1.4.0 introduces new trait definitions, json_conv_traits, that support non-throwing conversions and uses-allocator construction.

See Eigen::Matrix example for an example of specializing json_conv_traits for an Eigen matrix class.

See User-allocator construction example for an example that illustrates uses-allocator construction for types with json_conv_traits defined.

For backwards compatability, json_conv_traits defaults to json_type_traits if a type conversion is undefined.

Convenience macros

jsoncons includes some convenience macros for generating reflection traits classes. Until 1.4.0, these macros generated json_type_traits class templates. Since 1.4.0, they generate json_conv_traits class templates, as well as some additional traits that support streaming.