Skip to content

Releases: danielaparker/jsoncons

Release 0.143.1

03 Jan 02:03

Choose a tag to compare

Bug fix:

  • v0.143.1 fixs a bug in the jsonpath filter < comparison operator that was introduced in v0.143.0

Enhancements:

  • j.as<int>(), j.as<uint64_t>() etc. supported for binary, octal and hex string values,
    in addition to decimal string values.

  • Includes json_type_traits specialization for integer keyed maps, with conversion
    to/from string keys in a basic_json.

  • The json_type_traits specializations for type T generated by the convenience macros now include a specialization of
    is_json_type_traits_declared<T> with member constant value equal true.

  • New basic_json member function json_type type()

  • New basic_json member function get_value_or that gets a value as type T if available,
    or a default value if not:

    template <class T,class U>
    T get_value_or(const string_view_type& name, U&& default_value) const;

get_value_or is the preferred alternative to

template<class T>
T get_with_default(const string_view_type& name, const T& default_value) const

Note that get_value_or requires that the first template parameter T be specified explicitly (unlike get_with_default)

Changes:

  • The basic_json get_with_default(name) function, which returned a const reference
    to the value if available and to a json null constant if not,
    has been deprecated and renamed to at_or_null(name). Rationale: get_with_default(name)
    is more like at(name) (both return a const reference) than
    get_with_default(name,default_value) (which returns a value.)

  • The tag type bstr_arg_t has been renamed to byte_string_arg_t, and the constant
    bstr_arg to byte_string_arg.

  • The cbor_content_handler public member functions typed_array() and private virtual functions
    do_typed_array() have been moved to basic_json_content_handler. The do_typed_array()
    private virtual functions have been given default implementations. cbor_content_handler
    has been deprecated.

  • Replaced Martin Moene's span-lite with simpler implementation until std::span is available
    (primarily for typed array interface.)

Release 0.142.0

23 Dec 06:03

Choose a tag to compare

Defect fixes:

Release 0.141.0

06 Dec 03:38

Choose a tag to compare

Name change:

  • The names JSONCONS_ALL_PROPERTY_TRAITS_DECL, JSONCONS_N_PROPERTY_TRAITS_DECL,
    JSONCONS_TPL_ALL_PROPERTY_TRAITS_DECL and JSONCONS_N_PROPERTY_TRAITS_DECL
    have been deprecated and renamed to JSONCONS_ALL_GETTER_SETTER_TRAITS_DECL,
    JSONCONS_N_GETTER_SETTER_TRAITS_DECL,JSONCONS_TPL_ALL_GETTER_SETTER_TRAITS_DECL
    and JSONCONS_TPL_N_GETTER_SETTER_TRAITS_DECL. Rationale: naming consistency.

Enhancements:

  • New tag types json_object_arg_t, json_array_arg_t and bstr_arg_t
    have been introduced that make it simpler to construct basic_json values
    of objects, arrays and byte strings.

Release 0.140.0

28 Nov 07:10

Choose a tag to compare

Changes to the json_type_traits convenience macros:

  • In Issue 190, Twan Springeling
    raised an issue with the macro JSONCONS_GETTER_CTOR_TRAITS_DECL, that it did not come
    with "strict" and "non-strict" versions. In this release we introduce new macros, where
    _N_ is mnemonic for the number of mandatory properties provided (possibly zero), and ALL is
    mnemonic for all properties are mandatory:
JSONCONS_N_GETTER_CTOR_TRAITS_DECL(class_name,num_mandatory_params,
                                   getter_name0,
                                   getter_name1,...) // (11)

JSONCONS_ALL_GETTER_CTOR_TRAITS_DECL(class_name,
                                     getter_name0,getter_name1,...) // (12)

JSONCONS_TPL_N_GETTER_CTOR_TRAITS_DECL(num_template_params,
                                       class_name,num_mandatory_params,
                                       getter_name0,getter_name1,...) // (13)

JSONCONS_TPL_ALL_GETTER_CTOR_TRAITS_DECL(num_template_params,
                                         class_name,
                                         getter_name0,getter_name1,...) // (14)

JSONCONS_N_GETTER_CTOR_NAMED_TRAITS_DECL(class_name,num_mandatory_params,
                                         (getter_name0,"name0"),
                                         (getter_name1,"name1")...) // (15)

JSONCONS_ALL_GETTER_CTOR_NAMED_TRAITS_DECL(class_name,
                                          (getter_name0,"name0"),
                                          (getter_name1,"name1")...) // (16)

JSONCONS_TPL_N_GETTER_CTOR_NAMED_TRAITS_DECL(num_template_params,
                                             class_name,num_mandatory_params,
                                             (getter_name0,"name0"),
                                             (getter_name1,"name1")...) // (17)

JSONCONS_TPL_ALL_GETTER_CTOR_NAMED_TRAITS_DECL(num_template_params,
                                               class_name,
                                               (getter_name0,"name0"),
                                               (getter_name1,"name1")...) // (18)
  • When the traits generated by e.g. JSONCONS_N_GETTER_CTOR_TRAITS_DECL need to pass an argument to a
    constructor that is not present in the JSON, they pass a default constructed parameter value.
    The legacy macros e.g. JSONCONS_GETTER_CTOR_TRAITS_DECL remain, and have the same meaning as before, but are deprecated.

  • With the introduction of the JSONCONS_POLYMORPHIC_TRAITS_DECL macro,
    and the support for polymorhic types, there comes a problem with the "non-strict" macros
    JSONCONS_MEMBER_TRAITS_DECL, JSONCONS_PROPERTY_TRAITS_DECL, JSONCONS_SETTER_GETTER_TRAITS_DECL, etc.,
    when a class has non-mandatory properties. Type selection is based on the presence of properties,
    but the json_type_traits generated by the non-strict macros don't know which properties are mandatory
    and which non-mandatory, hence type selection becomes impossible when members are absent in
    the JSON. For this reason, twelve new _N_ macros have been introduced to allow you to specify which properties
    are mandatory (_N_ is mnemonic for number of mandatory properties):

JSONCONS_N_MEMBER_TRAITS_DECL(class_name,num_mandatory_params,
                              member_name0,member_name1,...)

JSONCONS_TPL_N_MEMBER_TRAITS_DECL(num_template_params,
                                  class_name,num_mandatory_params,
                                  member_name0,member_name1,...)

JSONCONS_N_MEMBER_NAMED_TRAITS_DECL(class_name,num_mandatory_params,
                                    (member_name0,"name0"),
                                    (member_name1,"name1")...)

JSONCONS_TPL_N_MEMBER_NAMED_TRAITS_DECL(num_template_params,
                                        class_name,num_mandatory_params,
                                        (member_name0,"name0"),
                                        (member_name1,"name1")...)

JSONCONS_N_GETTER_CTOR_TRAITS_DECL(class_name,num_mandatory_params,
                                   getter_name0,
                                   getter_name1,...)

JSONCONS_TPL_N_GETTER_CTOR_TRAITS_DECL(num_template_params,
                                       class_name,num_mandatory_params,
                                       getter_name0,getter_name1,...)

JSONCONS_N_GETTER_CTOR_NAMED_TRAITS_DECL(class_name,num_mandatory_params,
                                         (getter_name0,"name0"),
                                         (getter_name1,"name1")...)

JSONCONS_TPL_N_GETTER_CTOR_NAMED_TRAITS_DECL(num_template_params,
                                             class_name,num_mandatory_params,
                                             (getter_name0,"name0"),
                                             (getter_name1,"name1")...)

JSONCONS_N_PROPERTY_TRAITS_DECL(class_name,get_prefix,set_prefix,num_mandatory_params,
                                property_name0,property_name1,...)

JSONCONS_TPL_N_PROPERTY_TRAITS_DECL(num_template_params,
                                    class_name,get_prefix,set_prefix,num_mandatory_params,
                                    property_name0,property_name1,...)

JSONCONS_N_GETTER_SETTER_NAMED_TRAITS_DECL(class_name,num_mandatory_params,
                                          (getter_name0,setter_name0,"name0"),
                                          (getter_name1,setter_name1,"name1")...)

JSONCONS_TPL_N_GETTER_SETTER_NAMED_TRAITS_DECL(num_template_params,
                                               class_name,num_mandatory_params,
                                               (getter_name0,setter_name0,"name0"),
                                               (getter_name1,setter_name1,"name1")...)
  • The legacy non-strict macros remain, and have the same meaning as before, but are deprecated.

  • For consistency with the new naming, and to allow the legacy JSONCONS_GETTER_CTOR_TRAITS_DECL to
    keep the same meaning for backwards compatibility, the _STRICT_ names are deprecated
    and renamed substituting _ALL_ for STRICT.

See json_type_traits
for complete documentation of the convenience macros.

Release 0.139.0

20 Nov 18:20

Choose a tag to compare

Enhancements:

  • New convenience macro for generating json_type_traits from getter and setter functions
    that will serialize to the stringified property names,
JSONCONS_PROPERTY_TRAITS_DECL(class_name,get_prefix,set_prefix,
                              property_name0,property_name1,...) 

JSONCONS_STRICT_PROPERTY_TRAITS_DECL(class_name,get_prefix,set_prefix,
                                     property_name0,property_name1,...) 

JSONCONS_TPL_PROPERTY_TRAITS_DECL(num_template_params,
                                  class_name,get_prefix,set_prefix,
                                  property_name0,property_name1,...)   

JSONCONS_TPL_STRICT_PROPERTY_TRAITS_DECL(num_template_params,
                                         class_name,get_prefix,set_prefix,
                                         property_name0,property_name1,...) 

Release 0.138.0

17 Nov 23:46

Choose a tag to compare

Defect fix:

  • Fixes issue in csv_parser parsing a CSV file with mapping_kind::m_columns,
    when parsing a quoted string containing a numeric value, processing it as a
    number rather than as a string.

Changes:

  • It is no longer neccessay to place a semicolon after JSONCONS_TYPE_TRAITS_FRIEND

Enhancements:

  • New convenience macro to master for generating json_type_traits for polymorphic types,
    based on the presence of properties,
JSONCONS_POLYMORPHIC_TRAITS_DECL(base_class_name,derived_class_name0,derived_class_name1,...) 
  • The convenience macros JSONCONS_MEMBER_TRAITS_DECL, JSONCONS_STRICT_MEMBER_TRAITS_DECL,
    JSONCONS_TPL_MEMBER_TRAITS_DECL, JSONCONS_TPL_STRICT_MEMBER_TRAITS_DECL,
    JSONCONS_MEMBER_TRAITS_NAMED_DECL, JSONCONS_STRICT_MEMBER_TRAITS_NAMED_DECL,
    JSONCONS_TPL_MEMBER_TRAITS_NAMED_DECL, and JSONCONS_TPL_STRICT_MEMBER_TRAITS_NAMED_DECL
    now allow you to have const or static const data members that are serialized.

  • basic_csv_encoder now supports json values that map to multi-valued fields and
    json objects where each member is a name-array pair.

  • basic_csv_parser and basic_csv_encoder now support nan, infinity,
    and minus infinity substitution

Deprecated basic_csv_options functions removed:

  • basic_csv_options& column_names(const std::vector<string_type>&)
  • basic_csv_options& column_defaults(const std::vector<string_type>& value)
  • column_types(const std::vector<string_type>& value)
    (Instead, use the versions that take comma-delimited strings)

Release 0.137.0

04 Nov 20:34

Choose a tag to compare

Defect fixes:

  • Fixes GCC 9.2 warning: ‘class jsoncons::json_exception’
    has virtual functions and accessible non-virtual destructor,
    contributed by KonstantinPlotnikov.

Enhancements:

  • Includes Martin Moene's span-lite to support a C++20-like span in the jsoncons namespace.

  • Includes enhancements to the CBOR encode and decode classes and functions to support the
    CBOR extension Tags for Typed Arrays.
    The implementation uses the span class.

Changes:

  • The json_options parameter to precision() has been changed from int to int8_t

  • The json_options parameter to indent_size() has been changed from size_t to uint8_t

  • The csv_options parameter to precision() has been changed from int to int8_t

  • The CSV extension enum name quote_style_type has been deprecated and renamed to quote_style_kind.

  • The CSV extension enum name mapping_type has been deprecated and renamed to mapping_kind.

  • The do_ virtual functions in basic_json_content_handler have been augmented with a std::error_code
    output parameter, e.g.

    virtual bool do_begin_object(semantic_tag tag, const ser_context& context, std::error_code& ec) = 0;

Release 0.136.1

15 Oct 02:03

Choose a tag to compare

v0.136.1

Bug fixes:

  • This version fixes a defect in the erase functions for
    the order preserving basic_json specializations, in
    particular, for ojson (issue 188.)

Release 0.136.0

29 Sep 01:14

Choose a tag to compare

For consistency with other names, the names of the convenience macros below
for classes with templates and JSON with given names have been deprecated.

JSONCONS_MEMBER_TRAITS_NAMED_DECL
JSONCONS_STRICT_MEMBER_TRAITS_NAMED_DECL
JSONCONS_TEMPLATE_MEMBER_TRAITS_DECL
JSONCONS_STRICT_TEMPLATE_MEMBER_TRAITS_DECL
JSONCONS_TEMPLATE_MEMBER_TRAITS_NAMED_DECL
JSONCONS_STRICT_TEMPLATE_MEMBER_TRAITS_NAMED_DECL
JSONCONS_ENUM_TRAITS_NAMED_DECL
JSONCONS_GETTER_CTOR_TRAITS_NAMED_DECL
JSONCONS_TEMPLATE_GETTER_CTOR_TRAITS_DECL
JSONCONS_TEMPLATE_GETTER_CTOR_TRAITS_NAMED_DECL
JSONCONS_GETTER_SETTER_TRAITS_NAMED_DECL
JSONCONS_STRICT_GETTER_SETTER_TRAITS_NAMED_DECL
JSONCONS_TEMPLATE_GETTER_SETTER_TRAITS_NAMED_DECL
JSONCONS_STRICT_TEMPLATE_GETTER_SETTER_TRAITS_NAMED_DECL

They have been renamed to

JSONCONS_MEMBER_NAMED_TRAITS_DECL
JSONCONS_STRICT_MEMBER_NAMED_TRAITS_DECL
JSONCONS_TPL_MEMBER_TRAITS_DECL
JSONCONS_STRICT_TPL_MEMBER_TRAITS_DECL
JSONCONS_TPL_MEMBER_NAMED_TRAITS_DECL
JSONCONS_STRICT_TPL_MEMBER_NAMED_TRAITS_DECL
JSONCONS_ENUM_NAMED_TRAITS_DECL
JSONCONS_GETTER_CTOR_NAMED_TRAITS_DECL
JSONCONS_TPL_GETTER_CTOR_TRAITS_DECL
JSONCONS_TPL_GETTER_CTOR_NAMED_TRAITS_DECL
JSONCONS_GETTER_SETTER_NAMED_TRAITS_DECL
JSONCONS_STRICT_GETTER_SETTER_NAMED_TRAITS_DECL
JSONCONS_TPL_GETTER_SETTER_NAMED_TRAITS_DECL
JSONCONS_STRICT_TPL_GETTER_SETTER_NAMED_TRAITS_DECL

See json_type_traits

Release 0.135.0

25 Sep 21:23

Choose a tag to compare

New macros that generate the code to specialize json_type_traits from the getter and setter functions
and serialize to given names:

  • JSONCONS_GETTER_SETTER_TRAITS_NAMED_DECL(class_name,(getter_name0,setter_name0,"name0"),(getter_name1,setter_name1,"name1")...)

  • JSONCONS_STRICT_GETTER_SETTER_TRAITS_NAMED_DECL(class_name,(getter_name0,setter_name0,"name0"),(getter_name1,setter_name1,"name1")...)

  • JSONCONS_TEMPLATE_GETTER_SETTER_TRAITS_NAMED_DECL(num_template_params,class_name,(getter_name0,setter_name0,"name0"),(getter_name1,setter_name1,"name1")...)

  • JSONCONS_STRICT_TEMPLATE_GETTER_SETTER_TRAITS_NAMED_DECL(num_template_params,class_name,(getter_name0,setter_name0,"name0"),(getter_name1,setter_name1,"name1")...)

Support for disabling exceptions

  • Support compilation with exceptions disabled