tgockel / json-voorhees

A killer modern C++ library for interacting with JSON.
http://tgockel.github.io/json-voorhees/
Apache License 2.0
128 stars 18 forks source link

Add ability to insert discrimination key for polymorphic adapter. #115

Closed vexingcodes closed 6 years ago

vexingcodes commented 6 years ago

It is useful for a polymorphic_adapter to be able to insert the discrimination key itself. This allows derived types to be unaware of whether they are being directly serialized or if they are being generically serialized and need to insert the discriminator key. It also simplifies the adapter code for the derived types.

In addition to being able to insert the key, functionality was added to merely check if the key was correctly inserted by the derived type.

The default behavior to do neither insertion nor checking has been maintained. One has to opt-in to this new functionality.

The documentation was updated, and the unit test for polymorphic adapters was expanded.