Releases: danielaparker/jsoncons
Release 1.4.0
-
Fixed bug:
-
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
memberlossless_bignum
. Iftrue
, reads out of range floating point numbers
as strings with tagsemantic_tag::bigdec
. Defaults to true. -
New reflection trait definitions,
jsoncons::reflect::json_conv_traits
, that support non-throwing conversions and uses-allocator construction.
These replacejsoncons::json_type_traits
, but for backwards compatibility,json_conv_traits
defaults tojson_type_traits
if a type conversion is undefined. -
New non-throwing versions of the decode functions that return a
std::expected
-like result (likestd::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 (likestd::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>()
forbasic_json
that return astd::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 functionscombine_allocators
andtemp_allocator_only
have been
deprecated and will be removed in a future release. Usemake_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. Usejsoncons::csv::result_options{}
instead. -
basic_json::dump
andencode_json
overloads that take ajsoncons::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
andstaj_object_view
and corresponding factoriesstaj_array
andstaj_object
have been removed. staj_array_iterator
andstaj_object_iterator
objects are now constructed directly
from a cursor rather than through one of these view objects.- Classes
staj_array_iterator
andstaj_object_iterator
now havebegin
andend
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) { // ... }
- Classes
Release 1.3.2
-
Fixed bug:
- Git Issue #607: Fixed issue with
staj_object_view
andstaj_array_view
iterators that got introduced
as a consequence of a change in 1.3.1
- Git Issue #607: Fixed issue with
Release 1.3.1
-
Fixed bugs:
-
Git Issue #601: Removed the space before the suffix in the user-defined literal operators
_json
and_ojson
-
Git Issue #605: Fixed bug when parsing a JMESPath expression that has a function that is passed a binary expression argument, e.g. A || B.
-
In cursors, after a call to
read_to
following abegin_object
event, the cursorevent_type()
function returned
staj_event_type::begin_object
, even though the effective state of the cursor had changed tostaj_event_type::end_object
.
This is fixed. The state of the cursor after a call tonext
is the same as before. -
Fixed an edge case in
basic_csv_parser
, detected by Google fuzz, where the first line in the input file contains an empty line
and thecsv_mapping_kind
isn_rows
.
-
-
API Changes:
-
In JMESPath evaluation, 1.3.0 introduced late binding of variables to an initial (global) scope via parameters.
The parameters type has been changed fromstd::vector<std::pair<string_type,Json>>
tostd::map<string_type,Json>
. -
Added a member function
begin_position()
toser_context
.begin_position()
should
be preferred toposition()
when using filters to update JSON in place.
Currently the two accessors return the same value, but that may change in a future release. -
Added macros JSONCONS_VISITOR_RETURN_TYPE and JSONCONS_VISITOR_RETURN that are
#define'd tobool
andreturn true
respectively. For users that have implemented
classes that derive frombasic_json_filter
, and that have overriddenvisit_xxx
functions,
it is recommended to use these macros for the return type and return value rather than
bool
andreturn true
. This is for forward compatibility.
-
Release 1.3.0
-
Fixed bugs:
-
Git Issue #600: Added "-Wnull-dereference" to CI and worked around some false positives.
-
Git Issue #597: Invalid json schema compiled successfully
-
Git Issue #595: SIGABRT when serialising unmapped enum value
-
Fixed a jmespath issue with parenthesized expressions involving projections (wildcard expressions,
the flatten operator, slices and filter expressions) where the right parenthesis did not stop the projection.
For example, given JSON{"foo" : [[0, 1], [2, 3]]}
, the JMESPath query(foo[*])[0]
returned[0,2]
rather than the correct[0,1]
. -
Fixed a
json_encoder
formatting issue whenarray_object_line_splits
option set toline_split_kind::same_line
.
-
-
Implemented new features:
-
JMESPath Lexical Scoping using the new let expression
-
JMESPath evaluation now supports late binding of variables to an initial (global) scope
via parameters. -
New
json_options
membersallow_comments
andallow_trailing_comma
. These options should
be preferred over using an error handler.
-
Release 1.2.0
-
Fixed bugs:
- Git Issue #453: jsonpath length function with recursive select argument gives wrong result
-
Implemented new features:
-
Git issue #556: Support nested JSON to CSV. Add
flat
,column_mapping
, andmax_nesting_depth
options tobasic_csv_options
-
Git issue #585: Add
raw_tag()
accessor tobasic_cbor_cursor
. Add functionsbegin_object_with_tag
,
begin_array_with_tag
,uint64_value_with_tag
etc. tobasic_cbor_encoder
to support encoding values with
raw CBOR tags. -
Git issue #574: Support custom JSON Schema error messages with
errorMessage
keyword. Add
enable_custom_error_message
option toevaluation_options
.
-
Release 1.1.0
Release 1.0.0
-
API Changes
-
Non-const
basic_json::operator[const string_view_type& key]
no longer
returns a proxy type. The rationale for this change is given in Git Issue
#315. The new behavior for the non-const overload ofoperator[](const string_view_type& key)
is to return a reference to the value that is
associated withkey
, inserting a default constructed value with the key
if no such key already exists, which is consistent with the standard
librarystd::map
behavior. The new behavior for the const overload of
operator[](const string_view_type& key)
is to return a const reference
to the value that is associated withkey
, returning a const reference to
a default constructed value with static storage duration if no such key
already exists. -
Until 1.0.0, a buffer of text is supplied to
basic_json_parser
with a
call toupdate()
followed by a call toparse_some()
. Once the parser
reaches the end of the buffer, additional JSON text can be supplied to the
parser with another call toupdate()
, followed by another call to
parse_some()
. See Incremental parsing (until
1.0.0).
Since 0.179, an initial buffer of text is supplied to the parse with a
call toset_buffer
, and parsing commences with a call toparse_some
.
The parser can be constructed with a user provided chunk reader to obtain
additional JSON text as needed. See Incremental parsing (since
1.0.0). -
enum
bigint_chars_format
is deprecated and replaced by
bignum_format_kind
. Addedbignum_format
getter and setter functions
tobasic_json_options
, and deprecatedbigint_format
getter and setter
functions. Changed defaultbignum_format
from
bigint_chars_format::base10
tobignum_format_kind::raw
. Rationale:
bigint_chars_format
was misnamed, as it applied tobigdec
as well as
bigint
numbers, and defaulting tobigint_chars_format::base10
produced
surprising results for users of our lossless number option. -
The URI argument passed to the jsonschema ResolveURI function object now
included the fragment part of the URI.
-
-
Fixed bugs:
-
Git Issue #554: [jsonpath] evaluation throws on json containing json_const_pointer
-
Git PR #560: [jmespath] When there are elements and the sum is indeed zero, avg function should return average value returned instead of a null value.
-
Git Issue #561: json_string_reader does not work correctly for empty string or string with all blanks
-
Git Issue #564: Fixed basic_json compare of double and non-numeric string
-
Git Issue #570: Fixed writing fixed number of map value/value pairs using cbor_encoder and msgpack_encoder
-
Fixed a number of issues in
uri::resolve
, used in jsonschema, related to abnormal references,
particulay ones containing dots in path segments.
-
-
Removed deprecated classes and functions:
- The jsonschema function
make_schema
, classesjson_validator
andvalidation_output
,
header filejson_validator.hpp
and examplelegacy_jsonschema_examples.cpp
,
deprecated in 0.174.0, have been removed.
- The jsonschema function
-
Enhancements:
-
Added stream output operator (
<<
) to uri class. -
Added
basic_json(json_pointer_arg_t, basic_json* j)
constructor to
allow abasic_json
value to contain a non-owning view of anotherbasic_json
value. -
Added constant
null_arg
so that a null json value can be
constructed with
json j{jsoncons::null_arg};
-
Custom jmespath functions are now supported thanks to PR #560
-
jsonschema now understands the 'uri' and 'uri-reference' formats
-
Release 0.178.0
Defect fixes:
-
Fixed issue with
jmespath::join function
through PR #546 -
Fixed issue with the path for cmake config files through PR #547
-
Related to #539, made the basic_json constructor
basic_json(const Allocator&)
consistent withbasic_json(json_object_arg_t, const Allocator& alloc = Allocator())
. -
Related to #539,
basic_json
copy construction now applies allocator traitsselect_on_container_copy_construction
to the allocator obtained fromother
. For pmr allocators, this gives a default constructed pmr allocator rather
than a copy of the allocator inother
.
Enhancements:
-
Improved the implementation of
basic_json
swap. Previously in some cases it would allocate. -
Improved the implementation of
basic_json
copy assignment. Reduced allocations when assigning from array to array and object to
object. -
Documented the rules for
basic_json
allocators here,
and added numerous tests for conformance to the rules. -
Added missing
basic_json
constructor
basic_json(json_array_arg_t,
std::size_t count, const basic_json& value, semantic_tag tag = semantic_tag::none,
const Allocator& alloc = Allocator());
Release 0.177.0
Release 0.176.0
Compiler support
-
Update to Supported compilers
documentation to reflect the compilers that are currently in continuous integration testing. -
Support for some ancient compilers, in particular g++ 4.8 and 4.9, has been dropped.
-
Accepted pr #519 to support build with with llvm-toolset-7 on CentOS 7.
-
We (and users) have seen some compilation errors with tests of
std::scoped_allocator_adaptor
using our sample stateful allocatorFreeListAllocator
in versions of clang predating version 11, and versions of g++ predating version 10. We've therefore excluded these tests when testing with
the older compilers.
Enhancements
basic_json
now supports using C++ 17 structured binding, so you can write
for (const auto& [key, value] : j.object_range())
{
std::cout << key << " => " << value << std::endl;
}
jsonschema extension defect fixes:
-
Fixed issue #520 where enabling format validation resulted in a premature abort to validation
-
Addressed issue #521 so that jsonschema now supports big integers
Other defect fixes:
- Resolved #518 about CUDA and int128 and float 128