Skip to content

Releases: danielaparker/jsoncons

Release 1.9.0

Choose a tag to compare

@danielaparker danielaparker released this 07 Aug 17:10
  • Fixed bugs:

    • Fixed issue identified by Google fuzz where a CBOR classical multi-dimensional array
      contained elements of typed array.

    • Git PR #727: fix CBOR parser issues the fuzzer exposed

  • Changes

    • The type name string_source has been deprecated and renamed to chars_source.

    • The class binary_iterator_source has been removed (replaced by iterator_source).

    • The type name order_preserving_policy has been deprecated and renamed to
      ordered_policy. For backwards compatibility the old name is aliased to the new name but
      will be removed in a future release.

    • The type name json_conv_traits has been deprecated and renamed to json_traits.
      For backwards compatibility the old name is aliased to the new name but
      will be removed in a future release.

  • Enhancements:

    • Until 1.9.0, cbor and msgpack cursors read key-value pairs
      and convert the key part into a string before making it
      avaliable to the cursor as a staj_events::key event .
      Since 1.9.0, cbor and msgpack cursors read key-value pairs
      and make both string and non-string keys available to the cursor
      as a value event ORed with a key flag (staj_events::key_flag).
      For backwards compatibility, staj_events::key is now defined as
      staj_events::string_value | staj_events::key_flag.

    • For the common case of CBOR or MessagePack unsigned integer keys,
      the enum value id has been added to sjaj_events,
      defined as staj_events::uint64_value | staj_events::key_flag.

      cbor::cbor_bytes_cursor cursor{data};
      while (!cursor.done())
      {
          switch (cursor.current().event_type())
          {
              case staj_events::id:
                  auto id = cursor.current().get<uint64_t>();
                  // handle unsigned integer key event
                  break;
          }
      }
    • When decoding a CBOR or MessagePack array of maps that have unsigned
      integer keys, code like

    auto m = cbor::decode_cbor<std::vector<std::map<uint64_t, std::string>>>(data);

    produces the same result as 1.8.0, but no longer results in conversions
    from integer to string and back to integer.

    • Reduced allocations when parsing BSON, CBOR, MessagePack and UBJSON.

    • JSONCONS_ALL_MEMBER_TRAITS, JSONCONS_N_MEMBER_TRAITS,
      JSONCONS_ALL_MEMBER_NAME_TRAITS, and JSONCONS_N_MEMBER_NAME_TRAITS now
      generate decode traits that support decode without an intermediate
      basic_json value.

Release 1.8.1

Choose a tag to compare

@danielaparker danielaparker released this 09 Jun 16:45

Release 1.8.1

  • Fixed bugs:

    • Git PR #717: fix misplaced #endif

Release 1.8.0

  • Fixed bugs:

    • Git PR #716: fix bigdec mantissa and exponent parsing

    • Git Issue #714: json_parser does not stop calling the visitor after visit_* signals an error via std::error_code

    • Git Issue #712/PR #713: quieten GCC 16 (spurious?) array-out-of-bounds warning

    • Git PR #711: Fix staj_event::as_double silently returning 0 for non-numeric strings

    • Git Issue #709: JSONCONS_N_MEMBER_TRAITS silently swallows mandatory-field errors when nested inside an optional parent member

    • Git Issue #702/ PR #703: JMESPath - Merge function can't merge when receiving a json_const_ref

    • Git PR #707: Nested CBOR Parser Fix

    • Git PR #705: JMESPath - Sort and sort_by functions can't sort when receiving a json_const_ref

    • Git PR #704: JMESPath Support rhs expression in multi_select_list

    • Git PR #701: Don't write extra value after some CBOR epoch timestamps

    • Git PR #700: Fix bad multiplier when writing some BSON datetimes

    • Fixed issue with cbor_encoder encoding of multi-dimensional CBOR typed arrays (with use_typed_arrays true.)

  • Changes:

    • The types json_pointer_arg_t and json_const_pointer_arg_t have been
      renamed to json_ptr_arg_t and const_json_ptr_arg_t, and the
      constants json_pointer_arg and json_const_pointer_arg have been
      renamed to json_ptr_arg and const_json_ptr_arg. The old names have been
      deprecated and will be removed in a future version. For now they are
      aliased to the new names.

    • Since 1.8.0, the basic_json copy constructor makes a deep copy of any const_json_ref
      and json_ref pointers it may hold. Until 1.8.0, it made a shallow copy. With
      this change, the basic_json::deep_copy() function is no longer needed, and has been
      deprecated.

    • The (undocumented but sometimes useful) class basic_json_diagnostics_visitor has
      been renamed to basic_tracing_json_visitor, and its header diagnostics_visitor.hpp
      to tracing_json_visitor.hpp. Rationale: naming consistency.

    • Until 1.8.0, when using the cursor api, it was necessary to supply a custom visitor
      to read a CBOR typed array, like this,

          struct my_cbor_visitor : public default_json_visitor
          {
              std::vector<double> v;
          private:
              bool visit_typed_array(const span<const double>& data,  
                  semantic_tag, const ser_context&, std::error_code&) override
              {
                  v = std::vector<double>(data.begin(),data.end());
                  return true;
              }
          };
      
          my_cbor_visitor visitor;
          cursor.read_to(visitor);
      

      Since 1.8.0, this will not work, read_to(visitor) will not result in a call to visit_typed_array.
      Instead, you can simply write,

          std::vector<double> v;
          cursor.read_typed_array(v);
      
    • Until 1.8.0, when reading a CBOR multidimensional arrays with typed array or classical array storage,
      and serializing to JSON, the result would mimic the CBOR storage, e.g.

          [[2,3,2], [1,2,3,4,5,6,7,8,9,10,11 12]]]
      

      Information about order (row-major or column-major) is lost, and formatting this way
      isn't compatible with our sample reflection traits for eigen matrices. Since 1.8.0,
      CBOR multidimensional arrays with row-major and column-major typed array storage
      and multi-dimensional arrays with row-major classical array storage are serialized
      as nested arrays, so the 2 x 3 x 2 3D array above, assuming row-major storage, becomes

          [[[1,2],[3,4],[5,6]],[[7,8],[9,10],[11,12]]]
      

      and with column-major typed array storage,

           [[[1,7],[3,9],[5,11]],[[2,8],[4,10],[6,12]]]
      

Enhancements:

  • The following virtual functions have been added to basic_staj_cursor,
    with specializations provided by basic_cbor_cursor, to support multi-dimensional array input:

    virtual bool is_mult_dim() const;
    virtual jsoncons::span<const std::size_t> extents() const;
    virtual mdarray_order order() const;
    
  • The following virtual functions have been added to basic_staj_cursor,
    with specializations provided by basic_cbor_cursor, to support
    typed array input:

    virtual bool is_typed_array() const;
    virtual typed_array_tags array_tag() const; 
    virtual jsoncons::span<uint8_t> array_buffer(); 
    virtual void to_end_array(); 
    
  • The following function has been added to basic_staj_cursor to support
    typed array input:

    template <typename T>
    void read_typed_array(T& v);
    

Release 1.7.0

Choose a tag to compare

@danielaparker danielaparker released this 27 Apr 02:55
  • Fixed bugs:

    • Git Issue #690: JMESPath let expression with operator in variable binding

    • Git Issue #697: Fixed warning when using wide characters and mapping to integer types narrower than wchar_t.

  • Changes

    • The jsonschema enum class walk_result has been renamed to walk_state.
      For backwards compatibility, the old name walk_result has been aliased to walk_state.
  • Enhancements:

    • Git Issue #692: The enum staj_event_type has been redefined as a BitMask Type,
      which means that the bitwise operators operator&, operator|, operator^, operator~, operator&=, operator|=, and operator^=
      are now defined for this type. The enum has been renamed to staj_events, following the convention that
      bitmask types have plural names, but aliased back to its original name staj_event_type for backwards compatibility.
      This allows us to write e.g.

      constexpr auto mask = staj_events::begin_array | staj_events::begin_object;
      if ((event_type & mask) != staj_events{}) {/*...*/}
    • The basic_json_pointer operator / now accepts a basic_string_view as a right-hand argument,
      and member function append now accepts a basic_string_view as an argument.

    • The class key_value has a new member name that returns a basic_string_view of the key.

    • Git Issue #695: Optimized for JMESPath short circuit of or and and operators via PR #698

    • jsonschema validation now supports validation of instances of jsoncons::pmr::json and jsoncons::pmr::ojson.
      Note that temporary allocations still use std::allocator.

    • Reduced allocations in jsonschema compilation and validation.

    • Git Discussion #678: "Make json-patches in custom report that will fix validating object", is now supported.

      • The json_schema function validate now suports providing a reporter that takes an optional user supplied patch as an argument.

      • The json_schema function walk now suports providing a reporter that takes an optional user supplied patch as an argument.

Release 1.6.0

Choose a tag to compare

@danielaparker danielaparker released this 23 Mar 12:48
  • Fixed bugs:

    • Git PR #673: Fix warning for non clang builds on linux

    • Git Issue #675: std::chrono conversion does not compile with libc++

    • Git PR #679: Fix double colon in url generator

    • Git PR #680: Added missing space after "found" in maximum_validator

    • Git PR #685: optimize semantic_tag::noesc write_string

    • Git PR #687: jmespath: allow rhs_expression in a keyvalue - expression

  • Changes:

    • Git PR #688,#689: jmespath: where possible without losing information,
      store the result of ceil and floor as basic_json integer values
      rather than double values.
  • Enhancements

    • Added toon-format extension

Release 1.5.0

Choose a tag to compare

@danielaparker danielaparker released this 02 Dec 10:01
  • Fixed bugs:

    • Git Issue #644: flatten/unflatten does not preserve arrays with more than 10 elements

    • Git Issue #652: Fixed issue with JSON Schema AdditionalProperties validator

    • Git Issue #653: Fixed issue with non existing default values being added in JSON Schema patch

    • Git Issue #659: Fixed jsonschema validation message

    • Git Issue #664: Fixed issue with detection of CBOR typed arrays that manifested itself on i386

    • Fixed issue with JSON encode option array_array_split_lines value line_split_kind::new_line
      not creating a new line

    • Fixed issue of JSON encode line split options applied to inner JSON structures
      conflicting with line split options applied to outer JSON structures, e.g. when
      root line splits are same_line and array within array line splits are multi_line.
      With the new behaviour the inner structure will remain same_line if the outer
      structure is same_line.

  • Changes

    • jsonpointer::unflatten now throws an exception if passed an empty object

    • The err_handler property of basic_json_options has been deprecated and will
      be removed in a future release. Use the allow_trailing_comma and allow_comments
      options instead.

    • Constructor overloads for basic_json_parser, basic_json_reader, basic_json_cursor,
      basic_csv_parser, basic_csv_reader and basic_csv_cursor that take an err_handler
      argument have been deprecated and will be removed in a future release. Use the
      allow_trailing_comma and allow_comments options instead.

    • The functors strict_json_parsing and allow_trailing_commas have been deprecated and
      will be removed in a future release. Use the allow_trailing_comma and allow_comments
      options instead.

    • The json_parser option lossless_bignum, when false, now applies to integer values
      as well as floating point values.

    • basic_json::is_bignum function has been changed to return true if the value
      is any string value tagged as bigint, bigdec, float128, or bigfloat
      (previously only bigint.)

    • basic_json has a function type() that returns a json_type enumeration,
      and the names of its enumerators have been changed. null_value, bool_value,
      int64_value, uint64_value, half_value, double_value, string_value,
      byte_string_value, array_value and object_value have been changed to
      null, boolean, int64, uint64, float16, float64, string,
      byte_string, array and object respectively. It's unlikely that we have
      many users of json_type, it isn't used in any of our examples, but for
      backwards compatibility the old names, now deprecated, have been typedef-ed to
      the new names.

    • The json_options member name line_splits has been renamed to root_line_spits.
      For backwards compatibility, the old name, now deprecated, behaves the same as the
      new name.

  • Enhancements

    • Git Discussions #594: Updated reflection traits to supports boost::optional

    • Git Discussions #651: Improved decode_json error messages

    • Git PR #647: Allow user configuration of JSONCONS_HAS_STD_FROM_CHARS

    • Git Discussions #654: Added an indent_char property to basic_json_options that supports tab indents

    • Git Discussions #660: Added reflection traits for read/write of enum values as integers.

Release 1.4.3

Choose a tag to compare

@danielaparker danielaparker released this 09 Oct 06:16
  • Fixed bug:

    • Git PR #640: jsonschema patch includes defaults for unmatch oneOf cases

    • Git PR #639: Regression: jsoncons fails to compile conversion from std::shared_ptr

Release 1.4.2

Choose a tag to compare

@danielaparker danielaparker released this 29 Sep 00:03
  • Fixed bug:

    • Git PR #638: Fixed issue with compiling with -fno_exceptions

Release 1.4.1

Choose a tag to compare

@danielaparker danielaparker released this 17 Sep 10:04

This patch fixes some issues reported with v1.4.0

  • Fixed bug:

    • Git PR #628: fixed uninitialized warning
    • Git Issue #631: Using std::variant with std::unordered_map can throw uncatchable exception
    • Git PR #633: Fix make_array() call
    • Git Issue #634: Regression in encode_json et al. from v1.3.2 to v1.4.0 with std::variant using std::map
    • Git Issue #635: Support construction of sorted_json_object from moved-in pairs

Release 1.4.0

Choose a tag to compare

@danielaparker danielaparker released this 27 Aug 02:57
  • Fixed bug:

    • Git PR #628: fixed uninitialized warning

    • Git Issue #622: fixed jmespath issue with uri resolution in patternProperties

    • Git Issue #620: Issue with JSONPath filter expression fixed through PR #621

  • Enhancements:

    • Use std::from_chars for chars to double conversion when supported in GCC and VC.
      This reverts the removal of this feature in 0.170.0, because of issue std::from_chars parsing fails tests on Windows.
      That issue has been addressed.

    • New basic_json_options member lossless_bignum. If true, reads out of range floating point numbers
      as strings with tag semantic_tag::bigdec. Defaults to true.

    • New reflection trait definitions, jsoncons::reflect::json_conv_traits, that support non-throwing conversions and uses-allocator construction.
      These replace jsoncons::json_type_traits, but for backwards compatibility, json_conv_traits defaults to json_type_traits if a type conversion is undefined.

    • New non-throwing versions of the decode functions that return a std::expected-like result (like std::expected<T,jsoncons::read_error>),

      • try_decode_json
      • try_decode_csv
      • try_decode_bson
      • try_decode_cbor
      • try_decode_msgpack
      • try_decode_ubjson
    • New non-throwing versions of the encode functions that return a std::expected-like result (like std::expected<void,jsoncons::write_error>),

      • try_encode_json
      • try_encode_csv
      • try_encode_bson
      • try_encode_cbor
      • try_encode_msgpack
      • try_encode_ubjson
    • New non-throwing accessor try_as<T>() for basic_json that return a std::expected<T,conversion_error>-like result,

  • Changes

    • Until now, the reflection traits generated by the convenience macros JSONCONS_ALL_MEMBER_TRAITS
      etc. produced JSON (or other formats) with object names in sorted order. After this release,
      they will produce JSON, BSON etc. with object names in the order that they appear as macro arguments.

    • The allocator_set helper functions combine_allocators and temp_allocator_only have been
      deprecated and will be removed in a future release. Use make_alloc_set instead.

    • The jsoncons::csv::result_options::value option has been deprecated and will be removed in a
      future release. See What does result_options::value do in json_query()?
      for the rationale for this change. Use jsoncons::csv::result_options{} instead.

    • basic_json::dump and encode_json overloads that take a jsoncons::indenting argument have been
      deprecated and will be removed in a future release. Use the _pretty overloads (introduced in 0.155.0)
      for prettified output (line indentation.)

  • Breaking change to staj iterator classes

    • Classes staj_array_view and staj_object_view and corresponding factories staj_array
      and staj_object have been removed.
    • staj_array_iterator and staj_object_iterator objects are now constructed directly
      from a cursor rather than through one of these view objects.
    • Classes staj_array_iterator and staj_object_iterator now have begin and end
      non-member functions for range-based for loop support.

    We don't expect this change will affect many users. In any case the change is simple, e.g.

      auto view = staj_object<std::string,json>(cursor);
      for (const auto& key_val : view)
      {
          // ...
      }
    

    becomes

      auto iter = staj_object_iterator<std::string,json>(cursor);
      for (const auto& key_val : iter)
      {
          // ...
      }
    

Release 1.3.2

Choose a tag to compare

@danielaparker danielaparker released this 13 Apr 18:35
  • Fixed bug:

    • Git Issue #607: Fixed issue with staj_object_view and staj_array_view iterators that got introduced
      as a consequence of a change in 1.3.1