Skip to content

Releases: Stiffstream/json_dto

v.0.3.4

22 Jul 08:49
Compare
Choose a tag to compare

Several new overloads for from_json and to_json functions with custom Reader_Writers (thanks to @omartijn for the PR).

A couple of new examples added.

v.0.3.3

30 Jan 13:18
Compare
Choose a tag to compare

This release contains a solution for #19 in the form of new functions inside a new json_dto::inside_array namespace.

This release also contains a fix for #23.

v.0.3.2

11 Jan 12:05
Compare
Choose a tag to compare

This is a bug-fix release. It fixes #20.

v.0.3.1

22 Feb 08:43
Compare
Choose a tag to compare

Support for std::int8_t and std::uint8_t added.

v.0.3.0

13 Dec 05:14
00e5313
Compare
Choose a tag to compare

Function templates set_attr_null_value are replaced by default_on_null.

Implementations of manopt_policy traits now have to implement method on_null that is being called when null value is found during deserialization. This change affects custom implementations of manopt_policy traits.

New binder mandatory_with_null_as_default added.

More details can be found in the corresponding section of README file.

v.0.2.15

06 Nov 06:08
Compare
Choose a tag to compare

This is just a maintenance release.

Compilation error with G++11 and C++20 fixed.

v.0.2.14

07 Oct 07:42
Compare
Choose a tag to compare

Adds an overload of to_stream that accepts pretty_writer_params_t (fixes #16).

v.0.2.13

29 Jun 10:26
Compare
Choose a tag to compare

New overload for json_dto::to_json that accepts parameters for RapidJSON's PrettyWritter:

my_data my_obj;
...
// Make default serialization, without pretty-writer:
std::string my_obj_image = json_dto::to_json(my_obj);

// Make serialization with pretty-writer:
std::string my_obj_pretty_image = json_dto::to_json(my_obj,
		json_dto::pretty_writer_params_t{}
				.indent_char(' ')
				.indent_char_count(3u)
				.format_options(rapidjson::kFormatSingleLineArray));

v.0.2.12

20 May 07:48
Compare
Choose a tag to compare

This version allows passing const- and rvalue references to functions mandatory, optional, optional_no_default, optional_null.

The template class json_dto::binder_t was refactored and now it uses several customization points (binder_data_holder_t, binder_read_from_implementation_t, binder_write_to_implementation_t). Those customization points can be used for solving tasks like described in #11. See more in the corresponding README section.

There are several new examples that show the new functionality: one, two, three.

v.0.2.11

16 Oct 06:28
58bdc34
Compare
Choose a tag to compare

The v.0.2.11 solves an issue of using custom Reader_Writer with the content of containers. For example:

// A custom Reader_Writer for (de)serializing std::uint32_t values.
struct my_uint_formatter {
  void read(std::uint32_t & v, ...) const {...}
  void write(const std::uint32_t & v, ...) const {...}
};

struct my_data {
  std::uint32_t single_value_;
  std::vector<std::uint32_t> several_values_;
  std::optional< std::vector<std::uint32_t> > optional_values_;

  template<typename Io> void json_io(Io & io) {
    io & json_dto::mandatory(
           // Simple usage of formatter for single uint32.
           my_uint_formatter{},
           "single", single_value_)
       & json_dto::mandatory(
           // Custom formatter should be applied for every item.
           json_dto::apply_to_content_t<my_uint_formatter>{},
           "several", several_values_)
       & json_dto::mandatory(
           // The first occurrence of apply_to_content is for std::optional.
           json_dto::apply_to_content_t<
             // The second occurrence of apply_to_content is for std::vector.
             json_dto::apply_to_content_t<
               my_uint_formatter
             >
           >{}
       ;
  }
};

Another new feature is the two new proxy types mutable_map_key_t and const_map_key_t that are used by json-dto for (de)serialization of keys in map-like structures (std::map, std::multimap, std::unordered_map and so on). It makes possible to overload read_json_value/write_json_value functions for a custom (de)serialization of non-string keys. For example:

// New overloads should be placed into json_dto namespace.
namespace json_dto {

void read_json_value(
   mutable_map_key_t<int> key,
   const rapidjson::Value & from)
{
  ... // Reading an int key from a string representation.
}

void write_json_value(
  const_map_key_t<int> key,
  rapidjson::Value & to,
  rapidjson::MemoryPoolAllocator<> & allocator)
{
  ... // Storing an int key as a string.
}

} // namespace json_dto

// Now we can use ints as keys in map-like structures.
struct my_data {
  std::map<int, int> ints_to_ints_;
  std::multimap<int, float> ints_to_floats_;
  ...
  template<typename Io> void json_io(Io & io) {
    io & json_dto::mandatory("ints_to_ints", ints_to_ints_)
       & json_dto::mandatory("ints_to_floats", ints_to_floats_)
       ...
       ;
  }
};

There are two new examples that show new features in the action: one, two.