Changes to basic_json::operator[]:
-
Removed
basic_json
proxy type. The rationale for this change is given in #315. -
The new behavior for the non-const overload of operator[](const string_view_type&) will follow the standard library
std::map
behavior, that is, return a reference to the value that is associated with the key, inserting a default constructed value with the key if no such key already exists. -
The new behavior for the const overload of operator[](const string_view_type&) will be to return a const reference to the value that is associated with key, returning a const reference to a default constructed value with static storage duration if no such key already exists.
Changes to basic_json_parser:
Until 0.179.0, a buffer of text is supplied to the parser with a call to update()
followed by a call to parse_some()
. Once the parser reaches the end of the buffer,
additional JSON text can be supplied to the parser with another call to update()
,
followed by another call to parse_some()
. See Incremental parsing (until 0.179.0).
Since 0.179, an initial buffer of text is supplied to the parse with a call to
set_buffer
, and parsing commences with a call to parse_some
. The parser can be
constructed with a user provided chunk reader to obtain additional JSON text
as needed. See Incremental parsing (since 0.179.0).
Enhancements:
-
New
basic_json(json_reference_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};
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());
Changes
-
Removed deprecated functions and type names identified in #487
-
Reduced the size of some initial
json_parser
allocations to help with #531
Defect fixes
-
Fixed #530 by making
jmespath_expression::evaluate
const -
Fixed #488 related to some standard libraries that don't support strings with stateful allocators.
-
Fixed issue identified in PR #532 with
basic_json::compare
function
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;
}
- Addressed issue #509 of over allocating memory due to alignment constraints through pr #510
jsonschema library 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
This release contains two breaking changes to recently added features.
Change to jsonpath::get function
- The return value for
jsonpath::get
has been changed from a pointer to the selected JSON value, or null if not found, to astd::pair<Json*,bool>
, where the bool component indicates whether the get operation succeeded.
Change to new jsonschema classes and functions introduced in 0.174.0:
- The overload of
json_schema<Json>::validate
that takes a callback must now be passed a lambda that returnswalk_result::advance
orwalk_result::abort
. This supports early exit from validation.
Note that this change does not affect the legacy pre-0.174.0 jsonschema
classes and functions (make_schema
, json_validator
).
Enhancement to jsonschema library:
- New
json_schema
member functionwalk
for walking through the schema.
Defect fixes:
- Fixed issue #499 with
nan_to_str
,inf_to_str
andneginf_to_str
Core library enhancements
- New
json_options
line_splits
option that addresses issue #490
jsonpath library enhancements
- New function
jsonpath::replace
analagous tojsonpointer::replace
, but for normalized paths.
jsonschema library enhancements
-
The jsonschema extension now supports Drafts 4, 6, 2019-09 and 2020-12 in addition to Draft 07.
-
New function
make_json_schema
that returns a representation of a compiled JSON Schema document. -
New class
validation_message
-
The legacy function
make_schema
and classesjson_validator
andvalidation_output
remain for backward compatibility, but have been deprecated.
-
Defect fixes
-
Fixed issue #485 where
basic_json
member names did not usepolymorphic_allocator
-
Addressed issue #482 by replacing
static_assert
with runtime exception
Defect fixes:
- Made all member functions of jsoncons::range const
- Removed use of deduced return types in jsonpath extension (C++ 14 feature)
- Fixed issue #473 about
bigint
and-Werror=stringop-overflow
Defect fixes:
-
Fixed issue #473 about
bigint
and-Werror=stringop-overflow
-
Fixed jmespath issue #471 about
jmespath::search
andojson
withAddressSanitizer
in macos environment -
Fixed jsonpointer issue with
json_pointer::parse
for empty string keys (which had implications for jsonschemadefinitions
keyword with empty keys.) -
Fixed jsonschema issue with
definitions
keyword with empty keys -
Fixed jsonschema issue #474 about JSON Schema maximum keyword error message
-
Fixed jsonschema issue with
multipleOf
keyword and type integer andmultipleOf
a floating point number -
Fixed jsonschema issue with the behavior of
$id
for rebasing in some keywords, particularlyif
,then
, andelse
.
Enhancements:
- The
jsonschema::make_schema
functions now support providing a retrieval URI, to initialize the base URI.
Defect fixes:
- Fixed issue #470 concerning jsonpath::make_expression with ec broken
Defect fixes:
- Fixed issue #469 affecting JSMESPath expressions with terminating CR
Enhancements to jsonpath
-
Added
result_option
sort_descending
. -
Added new classes
basic_json_location
,basic_path_element
, andbasic_path_node
. -
Added a new function
get
for selecting a single JSON value from a JSON document at a location represented by ajson_location
. -
Added a new function
remove
for removing a single JSON value from a JSON document at a location represented by ajson_location
. -
Added member function
select
tojsonpath_expression
. -
Added member function
select_paths
tojsonpath_expression
. -
Added member function
update
tojsonpath_expression
, to support update-in-place for compiled JSONPath expressions.
Enhancements to jsonpointer:
-
Added free functions
to_string
andto_wstring
. -
Added
append
function tobasic_json_pointer
.
Defect fixes:
-
Fixed issue #441 concerning misaligned allocation for string data.
-
Fixed issue #436 concerning overflow warning.
-
Changed internal variable names to avoid shadow warnings
-
Fixed signature of
dump_pretty
#438 -
Fixed
basic_json_decode_options
constructor #437
Enhancements:
-
Improved error messages (with field names) for invalid type mappings when using the
json_type_traits
convenience macros. -
Support char8_t and u8string for C++ 20
-
Added compare for bigint/bigdec/bigfloat as double or exact text match. This makes JSON Query work if you use
options.lossless_number(true)
for parsing JSON.
Enhancements:
-
basic_json
supports allocators that automatically propagate,-
std::pmr::polymorphic_allocator
-
std::scoped_allocator_adaptor
-
-
Defines aliases and alias templates for
basic_json
using polymorphic allocators in thejsoncons::pmr
namespace.
namespace jsoncons { namespace pmr {
template<class CharT, class Policy>
using basic_json = jsoncons::basic_json<CharT, Policy, std::pmr::polymorphic_allocator<char>>;
using json = basic_json<char,sorted_policy>;
using wjson = basic_json<wchar_t,sorted_policy>;
using ojson = basic_json<char, order_preserving_policy>;
using wojson = basic_json<wchar_t, order_preserving_policy>;
}}
-
Added a class
allocator_set
for holding an allocator for persistent data and an allocator for temporary allocations. -
Added the ability to pass an
allocator_set
object to functionsbasic_json::parse
,decode_json
,decode_csv
,decode_bson
,decode_cbor
,decode_msgpack
,decode_ubjson
,encode_json
,encode_csv
,encode_bson
,encode_cbor
,encode_msgpack
,encode_ubjson
. -
Added the ability to set a JSON parse error handler through options (rather than as a separate parameter.)
-
Added an error handler
allow_trailing_commas
Changes:
-
For users creating a custom
basic_json
with a user providedPolicy
, the namestring
inPolicy
must be changed tomember_key
. -
Non-propagating stateful allocators are no longer supported. Attempting to use a regular stateful allocator will produce a compile error. Regular stateful allocators must be wrapped with std::scoped_allocator_adaptor
-
Until 0.171.0, the
basic_json
functionstry_emplace
,emplace
, andemplace_back
allowed an allocator argument, and one was required when using stateful allocators. Since 0.171.0,try_emplace
,emplace
, andemplace_back
must not be passed an allocator argument, because bothstd::pmr::polymorphic_allocator
andstd::scoped_allocator_adaptor
use uses-allocator construction.
Note: Non-stateful custom allocators are supported as before.
-
The tag type
result_allocator_arg_t
and constantresult_allocator_arg
have been deprecated. -
The
jsonpath::json_replace
function no longer supports an optionalresult_options
parameter. -
The order preserving versions of
basic_json
,ojson
andwojson
, no longer use indexes to support search, but rely on sequential search instead. The feedback from users was that the additional allocations and overhead wasn't worth any gains, particularly as the number of members in JSON objects is typically not large.
Defect fixes
- Fixed issue danielaparker/jsoncons/#430 with
jsonpath::json_replace
Defect fixes
- Fixed issue with jsonschema default values (introduced in 0.170.0)
Defect fixes:
-
Fixed issue danielaparker/jsoncons/#418 where use of
std::aligned_storage
produced a diagnostic that it is deprecated in C++2023. -
Fixed issue danielaparker/jsoncons/#420 where
to_integer_base16
produced warnings when passed a wide character string. -
Fixed issue danielaparker/jsoncons/#391 where parsing JSON resulted in temporary allocations from
std::stable_sort
-
Fixed issue danielaparker/jsoncons/#421 where PVS-Studio found vulnerabilities in code.
-
Fixed issue danielaparker/jsoncons/#425 where
basic_byte_string::assign
andbasic_byte_string::append
failed to compile -
Fixed issue danielaparker/jsoncons/#426 where enum keyed maps didn't serialize correctly.
Changed:
- Removed static functions
jsonpath_expression::compile
. These have long been superceded with functionmake_expression
.
Defect fixes:
-
Fixed issue danielaparker/jsoncons/#416 where
length
operator failed for array of length zero. -
Fixed issue danielaparker/jsoncons/#411 where an overeager g++ 12.2.0 compiler reported a spurious
stringop-overflow
warning. -
Fixed issue danielaparker/jsoncons/#410 where
jsoncons::jsonpath::json_location::to_string
escaped only single quotes. -
Merged PR danielaparker/jsoncons/#406 that fixed multiple float parsing and boolean pretty print issues with wjson. This included reverting a change to use
std::from_chars
in 0.169.0.
Enhancements:
-
The jsonpath library now works with stateful allocators. In particular, the
make_expression
,json_query
andjson_replace
functions now accept an allocator argument for use in allocating
memory during expression compilation and evaluation. -
Merged PR danielaparker/jsoncons/#395 that added a
ser_context::end_position()
function.
Defect fixes:
-
Fixed issue with boost_interprocess examples not working with gcc, contributed by raplonu
-
Fixed and enhance basic_json_diagnostics_visitor, contributed by ecorm
Performance Enhancement:
- Use
std::from_chars
for chars to double conversion when supported in GCC and VC.
Enhancements:
-
Added a
size()
accessor function tobasic_staj_event
. If the event type is akey
or astring_value
or abyte_string_value
, returns the size of the key or string or byte string value. If the event type is abegin_object
or abegin_array
, returns the size of the object or array if known, otherwise 0. For all other event types, returns 0. -
Extended the parsers/cursors/encoder for JSON, CBOR, Msgpack, BSON, CSV, UBJSON so that they are resettable to new sources/sinks, contributed by ecorm
Changes:
- For consistency with library naming conventions, the directory
include/jsoncons/json_merge_patch
has been renamed toinclude/jsoncons/mergepatch
, the namespacejson_merge_patch
tomergepatch
, and the include filejson_merge_patch.hpp
tomergepatch.hpp
.
Defect fixes:
-
In release 0.167.0, the
csv_options::mapping()
accessor was renamed tocsv_options::mapping_kind()
, and the old name was deprecated but still useable. That release neglected to similarily rename the corresponding mutator, which is now addressed. -
Fixed csv parsing issue Exponential formatted numbers with leading zeros in exponent
-
Fixed Issue with assignment of an object_iterator to const_object_iterator using empty object. This issue affects some xcode osx users.
Bug Fix:
- Fixed an issue with the order preserving
ojson
erase function that takes two iterator arguments.
Enhancement:
- The
basic_json::erase
function return value, previously void, is now an iterator following the last removed element,
array_iterator erase(const_array_iterator pos);
object_iterator erase(const_object_iterator pos);
array_iterator erase(const_array_iterator first, const_array_iterator last);
object_iterator erase(const_object_iterator first, const_object_iterator last);
See Issue #363
Issues fixed:
- Fixed issue #355, "Array move constructor of basic_json copies provided array".
Issues fixed:
- Fixed issue #352
regarding
json_type_traits
macro failure when number of parameters reached 47.
Enhancement:
Increased maximum number of parameters in json_type_traits
macros
from 50 to 70.
Issues fixed:
-
Preseve original error messages when decoding into C++ data structures (related to issue #345)
-
Fixed issue #348) concerning compilation issue on OSx with C++11
Issues fixed:
-
Fixed issue #343 concerning segfault using JMESPath with Apple clang version 12.0.0 and x86_64-apple-darwin19.6.0.
-
Fixed issue #344 concerning compile error with gcc on archlinux with
-Werror=nonnull
.
Bugs fixed:
- Fixed jsonpath issue of normalized path component not being computed for expression, issue #338.
Bugs fixed:
-
Fixed issue #335. The 0b... notation used in a cbor header file has been replaced with 0x... notation. The 0b... notation used is only standard compliant with C++14 and later, although supported in some C++ 11 compilers.
-
Fixed issue with csv automatic number detection discovered while investigating issue #333.
Enhancements to jsonpointer extension:
-
Support construction of a
json_pointer
from a URI fragment representation of a JSON Pointer. -
Support stringifying a
json_pointer
to a URI fragment representation with theto_uri_fragment
function.
Bugs fixed:
- Fixed compilation error with clang version 8.0.1, issue #328.
Bugs fixed:
-
Fixed issue with a json_cursor hanging if opened with an empty file or string, detected by google/OSS-fuzz.
-
Fixed issue with the unary minus in a JSONPath filter expression, where an expression such as
$[?-@.key > -42]
would fail to parse. -
Fixed issue with private typedef and Intel C++ Compiler via PR #327
Changes:
- In the csv extension, the enum name
mapping_kind
has been renamed tocsv_mapping_kind
, and thecsv_options.mapping
function has been renamed tocsv_options.mapping_kind
. The old names have been deprecated but are still usable.
Enhancements:
-
Added support for JSON Merge Patch.
-
Added support in JSONPath expressions for '%' (modulus) operator
jsonpath bugs fixed:
- Fixed issue with normalized paths produced by JSONPath expressions with filters
jsonpath enhancements:
-
Added support for a parent selector, using the `^' symbol, following jsonpath-plus.
-
Implemented a number of performance optimizations.
jsonschema enhancements:
-
Improved error messages reported when compiling a schema document
-
Added a check that the "$schema" keyword, if present, is Draft 7.
Enhancements for bson extension:
-
Added semantic tags float128, id, regex, and code to support bson decode and encode for decimal128, ObjectId, regex, and Javascript code.
-
Support has been added for ObjectId, regex, decimal128 and the other non-deprecated bson types, as requested in issue #321.
-
Parsing now checks that the the number of bytes read for a document, embedded document and array matches the expected total.
Changes to jsonpath:
-
The values in the
result_options
bitmask have been changed fromenum class result_options {value=1, path=2, nodups=4|path, sort=8|path}; (until 0.164.0)
to
enum class result_options {value=0, nodups=1, sort=2, path=4}; (since 0.164.0)
In practice this means that any combination of these values that includes
result_options::value
has the same meaning as before, except that
result_options::value
can now be omitted. And any combination that includes
result_options::path
but not result_options::value
has the
same meaning as before.
Enhancements to jsonpath:
-
Functions now allow expressions to be passed as arguments, e.g.
$.books[?(ceil(@.price*100) == 2272)]
-
User provided custom functions are now supported
Changes to json_reader and csv_reader:
-
The typedefs
json_reader
andwjson_reader
have been deprecated, but for backwards compatibility they are still supported. They have been replaced byjson_string_reader
andwjson_string_reader
for string sources, andjson_stream_reader
andwjson_stream_reader
, for stream sources. -
The typedefs
csv_reader
andwcsv_reader
have been deprecated, but for backwards compatibility they are still supported. They have been replaced bycsv_string_reader
andwcsv_string_reader
for string sources, andcsv_stream_reader
andwcsv_stream_reader
, for stream sources.
Bugs fixed:
- Fixed a jsonpath issue where the two overloads of json_query and json_replace that took a callback function argument used a deprecated typedef in an SFINAE condition.
Bugs fixed:
- Fixed a jmespath issue with reusing compiled expressions, see #317
Bugs fixed:
-
Reversed change made in 0.163.0 to removal of duplicates with the
result_options::nodups
, reverting to previous behaviour (only consider as duplicates nodes with the exact same path starting from the root.) That seems to be the consensus. -
Fixed a memory leak in jsoncons::jsonpath::node_set, see #314, also related, #316
-
Fixed some gcc warnings about non-virtual destructors in the jsonpath, jmespath, and jsonschema extensions by making the destructors protected, see #313. Added the gcc compiler flag
-Wnon-virtual-dtor
for gcc in thetests/CMakeLists.txt
file.
Bugs fixed:
- Fixed a jsonpath issue with removal of duplicates with the
result_options::nodups
flag in the case of a union with different paths
- Fixed a sign-compare warning in android builds, #309
- Fixed a sign-compare warning
- Fixed a gcc warning with -Wsign-compare
-Wsign-compare
enabled for gcc test builds- Fixed some PVS-Studio warnings
Enhancements to jsonpointer
- The jsonpointer functions
get
,add
,add_if_absent
, andreplace
have an additonal overload with acreate_if_missing
parameter. If passedtrue
, creates key-object pairs when object keys are missing.
Enhancements to jsonpath
- Improved syntax checking for JSONPath unions
- Simplified function signatures for
make_expression
,json_query
, andjson_replace
.
Changes:
- The jsonpointer function
insert
has been deprecated and renamed toadd_if_absent
, for consistency with the other names.
The jsoncons::jsonpath
extension has been rewritten, see JSONPath extension revisited.
Enhancements to JSONPath extension
- Added a new function
make_expression
for creating a compiled JSONPath expression for later evaluation. - The
json_query
andjson_replace
functions now take an optionalresult_options
parameter that allows duplicate values (i.e. values with the same node paths) to be excluded from results, and for results to be sorted in path order.
Changes to json_query
-
The parameter
result_type
has been replaced by a bitmask typeresult_options
. For backwards compatability,result_type
has been typedefed toresult_options
, and thevalue
andpath
enumerators are still there. In addition,result_options
provides options for excluding duplicates from results, and for results to be sorted in path order. -
Until 0.161.0,
json_query
was limited to returning an array of results, a copy. With 0.161,json_query
allows the user to provide a binary callback that is passed two arguments - the path of the item and a const reference to the original item. -
Until 0.161.0,
json_replace
allowed the user to provide a unary callback to replace an item in the original JSON with a returned value. This overload is still there, but has been deprecated. With 0.161,json_replace
allows the user to provide a binary callback that is passed two arguments - the path of the item and a mutable reference to the original item.
Changes to supported JSONPath syntax
- Previous versions allowed optionally omitting the '$' representing the root of the
JSON instance in path selectors. This is no longer allowed. In 0.161.0, all path
selectors must start with either '$', if relative to the root of the JSON instance,
or '@', if relative to the current node. E.g.
store.book.0
is not allowed, rather,$store.book.0
. - Previous versions supported union of completely separate paths, e.g.
$..[name.first,address.city]
. 0.161.0 does too, but requires that the relative pathsname.first
andaddress.city
start with a '@', so the example becomes$..[@.name.first,@.address.city]
. - Previous versions supported unquoted names with the square bracket notation,
this is no longer allowed. E.g.
$[books]
is not allowed, rather$['books']
or$["books"]
. - Previous versions allowed an empty string to be passed as a path argument
to
json_query
. This is no longer allowed, a syntax error will be raised. - In 0.161.0, unquoted names in the dot notation are restricted to digits
0-9
, lettersA-Z
anda-z
, the underscore character_
, and unicode coded characters that are non-ascii. All others names must be enclosed with single or double quotes. In particular, names with hypens (-
) must be enclosed with single or double quotes.
Enhancements to JMESPath extension
- Function arity errors are now raised during compilation of the JMESPath expression rather than during evaluation.
Bugs fixed:
-
A C++20 change caused a
basic_json
overloaded operator '==' to be ambiguous despite there being a unique best viable function. Fixed. -
When parsing MessagePack buffers, lengths were being incorrectly parsed as signed integers. Fixed.
Enhancements:
- Added jsonschema extension that implements the JSON Schema Draft 7 specification for validating input JSON, #280
Changes:
- Until 0.160.0,
jsonpointer::flatten
, when applied to an an empty array or empty object, would produce a flattened value ofnull
rather than[]
or{}
. Since 0.160.0, it will produce[]
or{}
. For example, given{"bar":{},"foo":[]}
, the flattened output was {"/bar":null,"/foo":null}, but is now{"/bar":{},"/foo":[]}
.jsonpointer::unflatten
will now return the original object.
Deprecated function removed:
- The long deprecated
basic_json
functionto_string(const basic_json_encode_options<char_type>&, char_allocator_type&) const
has been removed (replacement isdump
).
Bugs fixed:
Changes:
- In the jsonpointer extension, the type names
json_ptr
andwjson_ptr
have been deprecated and renamed tojson_pointer
andwjson_pointer
.
Enhancements:
-
The json_pointer operators
/=
and/
now support integers. -
New override for
jsonpath::json_replace
that searches for all values that match a JSONPath expression and replaces them with the result of a given function, see #279 -
New factory function
jmespath::make_expression
to create compiled JMESPath expressions.
Bugs fixed:
- Fixed compilation error with gcc 11, #276 (thanks to Laurent Stacul)
Changes:
-
In 0.157.0, the
_NAME_
convenience macros were augmented to allow an optionalmode
parameter (JSONCONS_RDWR
orJSONCONS_RDONLY
) and three optional function object parameters,match
(value matches expected),from
(convert from type known to jsoncons) andinto
(convert into type known to jsoncons). In this release - 0.158.0 - the order of thefrom
andinto
function object parameters has been reversed. If you've providedfrom
andinto
function objects as arguments in your json traits convenience macros, you'll need to reverse their order, or if you've provided just afrom
function argument, you'll need to precede it withjsoncons::identity()
(orstd::identity()
if C++20). For the rationale for this change, see #277 -
Conversion errors during decode are now reported more consistently as
jsoncons::convert_error
, parsing errors remainjsoncons::ser_error
(or std::error_code
) as before.
Warnings fixed:
- Fixed C20 deprecated move_iterator access with arrow operator.
- Fixed PVS-Studio warnings
OSS-Fuzz issues fixed:
- Fixed OSS-Fuzz failed throw issue 25891 affecting
decode_ubjson
and potentially other decode functions. This means that decode functions will throw aser_error
instead of anassertion_error
in the presence of certain kinds of bad data.
Bugs fixed:
- The macros
JSONCONS_ALL_MEMBER_NAME_TRAITS
andJSONCONS_N_MEMBER_NAME_TRAITS
failed at compile time when provided with exactly two optional member arguments,JSONCONS_RDWR
followed by aMatch
function object (other cases were fine.) This has been fixed.
Change reverted:
- The name change
ser_error
tocodec_error
introduced in 0.157.0 has been reverted back toser_error
. Just in case anybody used it, the namecodec_error
has been typedefed toser_error
.
Changes:
- The name
ser_error
has been deprecated and renamed tocodec_error
.
Enhancements:
- The
_NAME_
convenience macros now allow an optionalmode
parameter (JSONCONS_RDWR
orJSONCONS_RDONLY
) and three function objects,match
(value matches expected),from
(convert from type known to jsoncons) andinto
(convert into type known to jsoncons), #267
Bugs fixed:
-
Fixed issue with jsonpath exception raised when querying empty string, #270
-
Included pull request #273 that fixes an issue with a misnamed macro (
BOOST_HAS_FLOAT128
instead ofJSONCONS_HAS_FLOAT128
) introduced in 0.156.0.
Bugs Fixed:
- Fixed issue with JSONCONS_N_MEMBER_NAME_TRAITS macro, #263
Enhancements:
-
New
basic_json(json_const_pointer_arg_t, const basic_json*)
constructor to allowbasic_json
values to contain non-owning views of otherbasic_json
values. -
New
deep_copy
function to make a deep copy of abasic_json
value that contains non-owning views on otherbasic_json
values. -
Reduced memory allocations in the jmespath extension using the new
basic_json(json_const_pointer_arg_t, const basic_json*)
constructor. -
Support for encoding
std::bitset
intobase16
encoded strings (JSON) and byte strings (binary formats), and decodingstd::bitset
from integer values, byte strings andbase16
encoded strings. -
Support 128 bit integer types
__int128
andunsigned __int128
, if supported on the platform.
Enhancements:
- Improved support for
bson_parser
to switch to array parsing when the BSON root object is a document butdecode_bson
needs to convert to anstd::array
,std::tuple
orstd::pair
.
Changes:
- The
semantic_tag
enum valuetimestamp
has been deprecated. It has been replaced byepoch_second
,epoch_milli
andepoch_nano
. The deprecatedtimestamp
value has been aliased toepoch_second
.
Enhancements:
-
Allow
bson_parser
to switch to array parsing when the root object is a document butdecode_bson
expects an array. -
Added
json_type_traits
support forstd::nullptr_t
-
Added
json_type_traits
support forstd::chrono::duration
-
Improved memory efficiency of jmespath extension
-
Added function
json_encode_pretty
as the preferred alternative
to thejson_encode
overload withindenting::indent
argument. -
Added
basic_json
member functiondump_pretty
as the preferred alternative
to thedump
overload withindenting::indent
argument. -
Generalized the
basic_json
member functiondump
and the functionsencode_json
andencode_csv
to write to any back insertable character container. -
Generalized the
basic_json
functionparse
and the functionsdecode_json
anddecode_csv
to read from any contiguous character sequence.
Bugs fixed:
-
Fixed g++ compile issue with -Wnoexcept compiler flag, #260
-
Fixed issue with creating a patch to remove array elements using
json_patch::from_diff
, #261 -
Fixed memory leak issue introduced in 0.154.2
Withdrawn
Bugs fixed:
- Fixed issue with encode_cbor overload for user type input and output stream, #259
Bugs fixed:
- Fixed issue with escaping special characters in the
jsonpath::flatten
function #255 - Added workaround for clang xcode 10 bug in
std::optional
implementation - Fixed bug in
basic_json
less operator with left hand sideuint64_value
and right hand sideint64_value
Changes:
-
The function name
jsonpointer::insert_or_assign
has been deprecated and renamed tojsonpointer::add
. Rationale: consistency with JSON Patch names. -
Until 0.154.0, the
position()
member function ofser_context
was defined for JSON name and string events only, and indicated the position of the first character of the name or string in the input. Since 0.154.0, theposition()
member function ofser_context
is defined for all JSON parse events, and indicates the position of the character at the beginning of the event, e.g. '[' for an array, '{' for an object, and '"' for a string. #256
Enhancements
- Added jmespath extension for JMESPath support, #204
- Added
json_type_traits
support forstd::variant
, #257
Bug fixes:
-
Fixed a bug in jsonpath array slice when the step component is negative and the start and stop components are omitted, #252. jsoncons jsonpath slices now have the same semantics as Python slices including for negative steps.
-
Fixed a bug in jsonpath line/column error reporting when using functions.
Bug fixes:
- Fixed a bug in jsonpath array slice when the end argument is negative, #250
Platform:
Bug fixes for BSON:
- Fixed int32 encoding error in the BSON encoder #243
- Fixed issue with default binary subtype when not specified, was 0, now 0x80 (user defined.)
Bug fixes:
-
Fixed decode issue with
json_type_traits
defined forset
,unordered_set
,multiset
,unordered_multiset
andforward_list
#242 -
Fixed issue with preserving original CBOR semantic tag for CBOR byte strings
associated with an unknown (to jsoncons) tag.
Enhancements:
-
basic_json::parse
,decode_json
,decode_csv
,decode_bson
,decode_cbor
,decode_msgpack
, anddecode_ubjson
now support reading data from a pair of LegacyInputIterators that specify a character or byte sequence. -
byte_string_view
now has an explicit constructor that allows any contiguous byte sequence container.
Bug fixes:
-
Fixed compile error when building with Android SDK level less than 21 #240
-
Fixed bson encode/decode of binary type (wasn't reading/writing subtype.)
Changes:
-
basic_json_compressed_encoder
has been deprecated and renamed tobasic_compact_json_encoder
. Rationale: consistency with other names. The typedefsjson_compressed_stream_encoder
,wjson_compressed_stream_encoder
,json_compressed_string_encoder
, andwjson_compressed_string_encoder
have been deprecated and renamed tocompact_json_stream_encoder
,compact_wjson_stream_encoder
,compact_json_string_encoder
, andcompact_wjson_string_encoder
. -
The factory function
make_array_iterator()
has been replaced bystaj_array()
. -
The factory function
make_object_iterator()
has been replaced bystaj_object()
. -
The constructors for
json_cursor
,csv_cursor
,bson_cursor
,cbor_cursor
,msgpack_cursor
, andubjson_cursor
that take a filter argument have been deprecated. Instead filters may be applied to a cursor using the pipe syntax, e.g.json_cursor cursor(is); auto filtered_c = cursor | filter1 | filter2;
Enhancements:
-
Generalized
basic_json(byte_string_arg_t, ...
constructor to accomodate any contiguous byte sequence container, which is a contiguous container that has member functionsdata()
andsize()
, and member typevalue_type
with size exactly 8 bits. Any of the values typesint8_t
,uint8_t
,char
,unsigned char
andstd::byte
(since C++17) are allowed. -
Generalized the functions
decode_bson
,decode_cbor
,decode_msgpack
anddecode_ubjson
to read from any contiguous byte sequence. -
Generalized the
json_visitor
member functionbyte_string_value
to accept any contiguous byte sequence argument. In particular this means thatbyte_string_value
can be called on an encoder with any bytes sequence argument. -
Generalized the functions
encode_bson
,encode_cbor
,encode_msgpack
andencode_ubjson
to write to any back insertable byte container. Any of the values typesint8_t
,uint8_t
,char
,unsigned char
andstd::byte
(since C++17) are allowed. -
Generalized the
json_type_traits
for maps to accomodate all key types that themselves have json_type_traits defined #241 -
Unknown CBOR tags preceding a byte string (unknown to jsoncons), MessagePack types associated with the MessagePack ext family, and bson binary subtypes associated with a binary value are now captured.
-
If in
basic_json
tag()
==semantic_tag::ext
, the functionext_tag()
will return a format specific tag associated with a byte string value. -
The
basic_json
constructor with parameterbyte_string_arg_t
now allows constructing a byte string associated with a format specific tag.
Bug fixes:
- Fixed
jsoncons::semantic_tag::uri
,jsoncons::semantic_tag::base64
andjsoncons::semantic_tag::base64url
applied to text strings incorrectly encoded into CBOR \238
Bug fixes:
-
Fixed eternal loop in csv parser #220
-
Fixed JSONPath issue with filter expressions containing regular expressions #233
-
Fixed OSS-Fuzz failed throw issue in CSV parser #232
-
Fixed OSS-Fuzz integer-overflow issue in CSV parser #231
-
Fixed OSS-Fuzz timeout issues #230
-
Fixed UBJSON issue parsing arrays with end markers #229
-
Fixed OSS-Fuzz memory allocation issues #228
-
Fixed OSS-Fuzz stack overflow issues #225
-
OSS-Fuzz failed throw issue in CBOR parser #235
-
Msg pack bin8 wrong format #237
Changes:
-
The cbor_option name
enable_typed_arrays
has been deprecated and renamed touse_typed_arrays
. -
jsonpointer::unflatten_method
has been deprecated and replaced withjsonpointer::unflatten_options
. -
The cursor functions named
read
have been deprecated and renamed toread_to
.
Enhancements:
-
Added classes bson_options, msgpack_options, and ubjson_options
-
Until this release, only JSON parsing supported a
max_nesting_depth
option. Since this release, JSON, BSON, CBOR, MessagePack and UBJSON all support amax_nesting_depth
option for both parsing and serializing. The default is 1024. -
UBJSON supports a
max_items
option for parsing and serializing. The default is 16,777,216.
Defects fixed:
-
Fixed jsonpath issue Union with spaces
-
Fixed jsonpath issue Bracket notation with empty string
-
Fixed jsonpath issue Bracket notation with empty string doubled quoted
Changes:
-
The names
basic_json_content_handler
andbasic_default_json_content_handler
have been deprecated and renamed tobasic_json_visitor
andbasic_default_json_visitor
. The private visitor functionsdo_xxx
have been renamed tovisit_xxx
. This change should be transparent to most users. -
The name
staj_event_type::name
has been deprecated and renamed tostaj_event_type::key
. Rationale: consistency with other names. The old name is still supported. -
The class
null_ser_context
has been deprecated. For defaults,ser_context()
is now used in place ofnull_ser_context()
.
Enhancements:
- Added jsonpointer
unflatten
function
Defects fixed:
- Fixed vs issue (since 0.148.0) with basic_json constructor disambiguation with
a combination of type tag and
std::initializer_list
arguments.
Non-breaking change:
- For consistency with naming conventions across
json_type_traits
convenience macros, macro names containingGETTER_CTOR
now containCTOR_GETTER
, e.g.JSONCONS_ALL_GETTER_CTOR_NAME_TRAITS
is nowJSONCONS_ALL_CTOR_GETTER_NAME_TRAITS
. The old names are still supported.
Enhancements:
- Added jsonpath functions
flatten
andunflatten
that flatten a json object or array to a single depth object of key-value pairs, and unflatten that object back to the original json.
Changes:
-
The
json_type_traits
convenience macro names ending inNAMED_TRAITS
have been deprecated and now end inNAME_TRAITS
, e.g. the old nameJSONCONS_ALL_GETTER_SETTER_NAMED_TRAITS
is nowJSONCONS_ALL_GETTER_SETTER_NAME_TRAITS
. Rationale: name consistency. -
Fixed some deprecated
json_type_traits
convenience macro names. All of the convenience macro names that have ever been deprecated should work.
Enhancements:
- Added overload with leading
temp_allocator_arg_t
parameter toencode_json
,encode_bson
,encode_csv
,encode_cbor
,encode_msgpack
andencode_ubjson
, which allows the user to supply a custom allocator that serialization will use for temporary work areas.
Fixed bugs:
- Fixed an issue with the
jsonpatch_error
class implementation ofwhat()
, likely related to issue #212
Enhancements:
-
Added support to the convenience macros
JSONCONS_N_GETTER_CTOR_TRAITS
andJSONCONS_ALL_GETTER_CTOR_NAMED_TRAITS
for-non mandatory members to be omitted altogether from the serialized JSON. These macros had been overlooked when this feature was added to the_N_
macros in 0.146.0. -
Added jsonpointer function
flatten
to flatten a json object or array into a single depth object of JSONPointer-value pairs. -
Added overload with leading
temp_allocator_arg_t
parameter todecode_json
,decode_bson
,decode_csv
,decode_cbor
,decode_msgpack
anddecode_ubjson
, which allows the user to supply a custom allocator that deserialization will use for temporary work areas.
Fixed issue with json_type_traits
specializations of std::shared_ptr<T>
and
std::unique_ptr<T>
when converting from JSON null.
Changes:
-
The name
rename_object_member_filter
has been deprecated and renamed torename_object_key_filter
-
The
json_content_handler
public functionname
has been deprecated and renamed tokey
. Rationale: in the future we'll likely support overloads for non-string keys for binary formats -
The
json_content_handler
private virtual functiondo_name
has been removed and replaced withdo_key
. Rationale: in the future we'll likely support overloads for non-string keys for binary formats
Enhancements:
-
New json_type_traits specialization for
std::shared_ptr<T>
forT
that is not a polymorphic class, i.e., does not have any virtual functions -
New json_type_traits specialization for
std::unique_ptr<T>
forT
that is not a polymorphic class -
For the
_N_
convenience macros that allow some non-mandatory members, the generated traitsto_json
function will exclude altogether empty values forstd::shared_ptr
andstd::unique_ptr
non-mandatory members, as they do currently forstd::optional
.
Defect fixes:
- Fixed issue with
json_type_traits
specialization for optional
Bug fixes:
- Fixed issue with jsoncons::optional
Bug fixes:
Name changes:
- The
json_type_traits
convenience macro names ending in_DECL
have been shortened by dropping the_DECL
suffix, e.g. the old nameJSONCONS_N_MEMBER_TRAITS_DECL
is nowJSONCONS_N_MEMBER_TRAITS
. The old names are still supported.
Enhancements:
-
Includes
json_type_traits
specialization forstd::optional
if C++ 17.nullopt
values are mapped to JSON null values. -
When encoding to JSON, the
json_type_traits
convenience macros will exlude altogether a non-mandatorystd::optional
nullopt
value from the JSON output.
Bug fixes:
Fixed issue json with preserve_order_policy does not preserve order of elements #210
Implemented feature requests:
- 208 Added member function to
basic_json
template <class T>
T as(byte_string_arg_t, semantic_tag hint) const;
Bug fix:
- Fixed bug in destructor of
typed_array
class
Enhancement:
- Improved performance of decoding CBOR typed arrays
Bug fix:
- 0.143.1 fixs a bug in the jsonpath filter < comparison operator that was introduced in 0.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 abasic_json
. -
The
json_type_traits
specializations for typeT
generated by the convenience macros now include a specialization ofis_json_type_traits_declared<T>
with member constantvalue
equaltrue
. -
New
basic_json
member functionjson_type type()
-
New
basic_json
member functionget_value_or
that gets a value as typeT
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 toat_or_null(name)
. Rationale:get_with_default(name)
is more likeat(name)
(both return a const reference) thanget_with_default(name,default_value)
(which returns a value.) -
The tag type
bstr_arg_t
has been renamed tobyte_string_arg_t
, and the constantbstr_arg
tobyte_string_arg
. -
The
cbor_content_handler
public member functionstyped_array()
and private virtual functionsdo_typed_array()
have been moved tobasic_json_content_handler
. Thedo_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.)
Defect fixes:
- Fixed csv documentation showing the wrong header file includes
- Fixed jsonpath issue json_query() is reordering arrays
- Fixed jsonpath issue with recursive descent reported in Alignment on JSONPath implementations across languages
Name change:
- The names
JSONCONS_ALL_PROPERTY_TRAITS_DECL
,JSONCONS_N_PROPERTY_TRAITS_DECL
,JSONCONS_TPL_ALL_PROPERTY_TRAITS_DECL
andJSONCONS_N_PROPERTY_TRAITS_DECL
have been deprecated and renamed toJSONCONS_ALL_GETTER_SETTER_TRAITS_DECL
,JSONCONS_N_GETTER_SETTER_TRAITS_DECL
,JSONCONS_TPL_ALL_GETTER_SETTER_TRAITS_DECL
andJSONCONS_TPL_N_GETTER_SETTER_TRAITS_DECL
. Rationale: naming consistency.
Enhancements:
- New tag types
json_object_arg_t
,json_array_arg_t
andbstr_arg_t
have been introduced that make it simpler to constructbasic_json
values of objects, arrays and byte strings.
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 thejson_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_
forSTRICT
.
See json_type_traits for complete documentation of the convenience macros.
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,...)
JSONCONS_POLYMORPHIC_TRAITS_DECL
now specializesjson_type_traits
forstd::unique_ptr<base_class>
in addition tostd::shared_ptr<base_class>
.
Defect fix:
- Fixes issue in
csv_parser
parsing a CSV file withmapping_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 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
, andJSONCONS_TPL_STRICT_MEMBER_TRAITS_NAMED_DECL
now allow you to haveconst
orstatic 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
andbasic_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)
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 toprecision()
has been changed fromint
toint8_t
-
The
json_options
parameter toindent_size()
has been changed fromsize_t
touint8_t
-
The
csv_options
parameter toprecision()
has been changed fromint
toint8_t
-
The CSV extension enum name
quote_style_type
has been deprecated and renamed toquote_style_kind
. -
The CSV extension enum name
mapping_type
has been deprecated and renamed tomapping_kind
. -
The
do_
virtual functions inbasic_json_content_handler
have been augmented with astd::error_code
output parameter, e.g.virtual bool do_begin_object(semantic_tag tag, const ser_context& context, std::error_code& ec) = 0;
Defect fixes:
- This version fixes a defect in the
erase
functions for the order preservingbasic_json
specializations, in particular, forojson
(issue 188.)
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
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
-
Fixed Compilation issue #178.
-
The name
jsonpointer::address
has been deprecated and renamed tojsonpointer::json_ptr
-
basic_json::contains
declarednoexcept
-
Support stateful result and work allocators in
json_decoder
-
Support stateful work allocators in
basic_json_reader
,basic_json_parser
,basic_csv_reader
andbasic_csv_parser
.
-
Deprecation warnings should now show for all supported versions of GCC and clang
-
New single argument
basic_json::get_value_with_default
, which has default valuebasic_json::null()
, to replace deprecatedbasic_json::get
. -
basic_json::get_value_with_default
now returns the default value if abasic_json
has a null value, previously threw.
- Fixed vs2019 warnings
Changes
-
The name
JSONCONS_TEMPLATE_STRICT_MEMBER_TRAITS_DECL
has been deprecated and renamed toJSONCONS_STRICT_TEMPLATE_MEMBER_TRAITS_DECL
-
The enum name
jsoncons::chars_format
used injson_options
andcsv_options
has been deprecated and renamed tofloat_chars_format
. -
The function name
floating_point_format()
used injson_options
andcsv_options
has been deprecated and renamed tofloat_format
.
New macros that serialize to given names (instead of the c++ names)
JSONCONS_MEMBER_TRAITS_NAMED_DECL(class_name,(member_name0,"name0"),(member_name1,"name1")...)
JSONCONS_STRICT_MEMBER_TRAITS_NAMED_DECL(class_name,(member_name0,"name0"),(member_name1,"name1")...)
JSONCONS_TEMPLATE_MEMBER_TRAITS_NAMED_DECL(num_template_params,class_name,(member_name0,"name0"),(member_name1,"name1")...)
JSONCONS_STRICT_TEMPLATE_MEMBER_TRAITS_NAMED_DECL(num_template_params,class_name,(member_name0,"name0"),(member_name1,"name1")...)
JSONCONS_GETTER_CTOR_TRAITS_NAMED_DECL(class_name,(getter_name0,"name0"),(getter_name1,"name1")...)
JSONCONS_ENUM_TRAITS_NAMED_DECL(enum_type_name,(identifier0,"name0"),(identifier1,"name1")...)
Deprecated features removed
- Constructor
basic_json(double, const floating_point_options&, semantic_tag)
Bug fix
- Fixed issue with serializing a C++ standard library container class to a binary format, and getting an indefinite length array or map.
Enhancements
- New non-member functions
make_array_iterator
andmake_object_iterator
for creating astaj_array_iterator
and astaj_object_iterator
(especially for CSV example)
Changes
- The
decode_csv
andencode_csv
functions have been moved fromcsv_reader.hpp
andcsv_encoder.hpp
tocsv.hpp
. Rationale: avoid circular reference with new implementation ofdecode_csv
.
Enhancements
basic_msgpack_parser
template class rewritten to avoid recursive function callsbasic_bson_parser
template class rewritten to avoid recursive function calls- New
basic_msgpack_cursor
template class withmsgpack_stream_cursor
andmsgpack_bytes_cursor
typedefs - New
basic_bson_cursor
template class withbson_stream_cursor
andbson_bytes_cursor
typedefs - New
basic_csv_cursor
template class withcsv_cursor
andwcsv_cursor
typedefs
Bug fix:
- Fixed issue with commented out first line of CSV file and column labels on next line
- Fixed issue with parsing BSON arrays
Bug fix:
- Fixed issue with
cbor_cursor
not reporting name events and terminal event
Enhancements
- New
basic_cbor_cursor
constructor that takes a filter parameter - Rewrote
basic_ubjson_parser
template class to avoid recursive function calls - New
basic_ubjson_cursor
template class withubjson_stream_cursor
andubjson_bytes_cursor
typedefs
- Fixed issue with deprecated class used in
decode_bson
,decode_msgpack
, anddecode_ubjson
New features:
-
Pull parsers for reporting CBOR parse events, cbor_stream_cursor for streams and cbor_bytes_cursor for buffers, have been added.
-
Added compile-time deprecation warnings
Changes:
-
The long since deprecated
basic_json
member typenull_type
has been removed. Instead, usejsoncons::null_type
. -
The return type of
key_value::key()
has been changed fromstring_view_type
tokey_type
. -
The classes
staj_filter
andfiltered_staj_reader
have been removed, instead, use a lambda expression in the constructor ofjson_pull_reader
. -
The names
default_parse_error_handler
andstrict_parse_error_handler
have been deprecated and renamed todefault_json_parsing
andstrict_json_parsing
. Rationale: these apply only to JSON. -
The typedef'ed names
json_encoder
,bson_encoder
,cbor_encoder
,csv_encoder
,cbor_encoder
,msgpack_encoder
, andubjson_encoder
have been deprecated and renamed tojson_stream_encoder
,bson_stream_encoder
,cbor_stream_encoder
,csv_stream_encoder
,cbor_stream_encoder
,msgpack_stream_encoder
, andubjson_stream_encoder
. Rationale: consistency for type names that are different for stream and string or bytes buffer specializations.
Changes
JSONCONS_NONDEFAULT_MEMBER_TRAITS_DECL
macro name deprecated and replaced withJSONCONS_STRICT_MEMBER_TRAITS_DECL
- basic_json function name
get_semantic_tag()
deprecated and replaced withtag()
- staj_reader function name
get_semantic_tag()
deprecated and replaced withtag()
Defect fixes:
-
This version fixes a defect in the macros
JSONCONS_MEMBER_TRAITS_DECL
etc. which meant that the generatedjson_traits_type
specializations were not compatible withwchar_t
sources and results. -
This version fixes a defect when the
operator[](const string_view_type& key)
is applied to a non constbasic_json
, which returns a proxy where the member associated with the key may or may not exist, and an accessor declarednoexcept
is called in the case that it doesn't. In particular, the accessorsis_xxx
andis<T>
now returnfalse
in this case.
New macros
JSONCONS_TEMPLATE_MEMBER_TRAITS_DECL(num_template_params,class_name,member_name1,member_name2,...)
JSONCONS_TEMPLATE_STRICT_MEMBER_TRAITS_DECL(num_template_params,class_name,member_name1,member_name2,...)
JSONCONS_TEMPLATE_GETTER_CTOR_TRAITS_DECL(num_template_params,class_name,getter_name1,getter_name2,...)
JSONCONS_TEMPLATE_MEMBER_TRAITS_DECL
, JSONCONS_TEMPLATE_STRICT_MEMBER_TRAITS_DECL
and JSONCONS_TEMPLATE_GETTER_CTOR_TRAITS_DECL
are for specializing json_type_traits
for template types. The parameter num_template_params
gives the number of template parameters.
JSONCONS_ENUM_TRAITS_DECL(enum_type_name,value1,value2,...)
JSONCONS_ENUM_TRAITS_DECL
allows you to encode and decode an enum type as a string.
Changes to staj streaming classes
-
json_cursor
no longer has a constructor that accepts astaj_filter
. Use afiltered_staj_reader
instead. -
The
staj_event
functionas<T>
has been deprecated and renamed toget<T>
. -
The
staj_event
functionaccept
has been renamed toread_to
.
Enhancements
-
New macro
JSONCONS_NONDEFAULT_MEMBER_TRAITS_DECL
, that, when decoding to a C++ object, requires all data members declared for the object to be present in the JSON (or other supported format.) -
Types that are specialized in
json_type_traits
are no longer required to have a public default constructor. In particular, types that are specialized usingJSONCONS_MEMBER_TRAITS_DECL
orJSONCONS_NONDEFAULT_MEMBER_TRAITS_DECL
may have a private default constructor +JSONCONS_TYPE_TRAITS_FRIEND
, and types that are specialized withJSONCONS_GETTER_CTOR_TRAITS_DECL
are not required to have a default constructor at all.
Enhancements
-
The
json_reader
andcsv_reader
constructors have been generalized to take either a value from which ajsoncons::string_view
is constructible (e.g. std::string), or a value from which asource_type
is constructible (e.g. std::istream). -
With this enhancement, the convenience typedefs
json_string_reader
andcsv_string_reader
are no longer needed, and have been deprecated.
Name change
- The name
json_pull_reader
has been deprecated (still works) and renamed tojson_cursor
Changes to bigfloat mapping
In previous versions, jsoncons arrays that contained
- an int64_t or a uint64_t (defines base-2 exponent)
- an int64_t or a uint64_t or a string tagged with
semantic_tag::bigint
(defines the mantissa)
and that were tagged with semantic_tag::bigfloat
, were encoded into CBOR bigfloats.
This behaviour has been deprecated.
CBOR bigfloats are now decoded into a jsoncons string that consists of the following parts
- (optional) minus sign
- 0x
- nonempty sequence of hexadecimal digits (defines mantissa)
- p followed with optional minus or plus sign and nonempty sequence of hexadecimal digits (defines base-2 exponent)
and tagged with semantic_tag::bigfloat
(before they were decoded into a jsoncons array and tagged with semantic_tag::bigfloat
)
jsoncons strings that consist of the following parts
- (optional) plus or minus sign
- 0x or 0X
- nonempty sequence of hexadecimal digits optionally containing a decimal-point character
- (optional) p or P followed with optional minus or plus sign and nonempty sequence of decimal digits,
and tagged with semantic_tag::bigfloat
are now encoded into CBOR bignums.
CMake build fix
- The CMAKE_BUILD_TYPE variable is now left alone if already set
Non-breaking changes to lighten semantic_tag
names
-
The
semantic_tag
enum valuesbig_integer
,big_decimal
,big_float
anddate_time
have been deprecated (still work) and renamed tobigint
,bigdec
,bigfloat
anddatetime
. -
The
json_content_handler
functionsbig_integer_value
,big_decimal_value
,date_time_value
andtimestamp_value
have been deprecated (still work.) Calls to these functions should be replaced by calls tostring_value
withsemantic_tag::bigint
,semantic_tag::bigdec
, andsemantic_tag::datetime
, and by calls toint64_vaue
withsemantic_tag::timestamp
. -
The enum type
big_integer_chars_format
has been deprecated (still works) and renamed tobigint_chars_format
. -
The
json_options
modifierbig_integer_format
has been deprecated (still works) and renamed tobigint_format
.
Non-breaking changes to ser_context
, ser_error
and jsonpath_error
- The function names
line_number
andcolumn_number
have been deprecated (still work) and renamed toline
andcolumn
.
-
Fixed bug in
json_encoder
withpad_inside_array_brackets
andpad_inside_object_braces
options -
Fixed issue with escape character in jsonpath quoted names.
-
Fixed pedantic level compiler warnings
-
Added doozer tests for CentOS 7.6 and Fedora release 24
-
New macro
JSONCONS_GETTER_CTOR_TRAITS_DECL
that can be used to generate thejson_type_traits
boilerplate from getter functions and a constructor.
defect fix:
- Fixed name of JSONCONS_MEMBER_TRAITS_DECL
jsonpath bug fixes:
-
Fixed bug in construction of normalized paths #177.
-
Fixed bug in jsonpath recursive descent with filters which could result in too many values being returned
Warning fix:
- Removed redundant macro continuation character #176
Non-breaking change to names (old name still works)
- The name JSONCONS_TYPE_TRAITS_DECL has been deprecated and changed to JSONCONS_MEMBER_TRAITS_DECL
Changes to jsonpath:
- jsonpath unions now return distinct values (no duplicates)
- a single dot immediately followed by a left bracket now results in an error (illegal JSONPath)
Enhancements to jsonpath
-
Union of completely separate paths are allowed, e.g.
$[firstName,address.city]
-
Names in the dot notation may be single or double quoted
Other enhancements:
basic_json
now supports operators<
,<=
,>
,>=
Changes:
- The template parameter
CharT
has been removed from the binary encodersbasic_bson_encoder
,basic_cbor_encoder
,basic_msgpack_encoder
, andbasic_ubjson_encoder
.
Enhancements:
-
Added macro JSONCONS_TYPE_TRAITS_FRIEND
-
Generalized the
csv_encode
,bson_encode
,cbor_encode
,msgpack_encode
andubjson_encode
functions to convert from any type T that implementsjson_type_traits
-
Generalized the
csv_decode
,bson_decode
,cbor_decode
,msgpack_decode
andubjson_decode
functions to convert to any type T that implementsjson_type_traits
Bug fix:
- Fixed issue with cbor_reader only reading tag values 0 through 23
Name change
- The name
json::semantic_tag()
has been renamed tojson::get_semantic_tag()
Non-breaking changes (old names still work)
- The name
semantic_tag_type
has been deprecated and renamed tosemantic_tag
- The names
json_serializer
,bson_serializer
,cbor_serializer
,csv_serializer
,msgpack_serializer
, andubjson_serializer
have been deprecated and renamed tojson_encoder
,bson_encoder
,cbor_encoder
,csv_encoder
,msgpack_encoder
, andubjson_encoder
- The names
bson_buffer_serializer
,cbor_buffer_serializer
,msgpack_buffer_serializer
, andubjson_buffer_serializer
have been deprecated and renamed tobson_bytes_encoder
,cbor_bytes_encoder
,msgpack_bytes_encoder
, andubjson_bytes_encoder
- The names
bson_buffer_reader
,cbor_buffer_reader
,msgpack_buffer_reader
, andubjson_buffer_reader
have been deprecated and renamed tobson_bytes_reader
,cbor_bytes_reader
,msgpack_bytes_reader
, andubjson_bytes_reader
Enhancements
- Cleanup of
encode_json
anddecode_json
functions and increased test coverage - Rewrote cbor_reader to avoid recursive function call
- CBOR reader supports stringref extension to CBOR
- New
cbor_options
haspacked_strings
option
Bug fix:
- Fixed issue with
j.as<byte_string_view>()
Non-breaking changes
- The name
is_json_type_traits_impl
has been deprecated and renamed tois_json_type_traits_declared
- The name
serializing_context
has been deprecated and renamed toser_context
- The name
serialization_error
has been deprecated and renamed toser_error
Enhancements
-
json
as_byte_string
attempts to decode string values ifsemantic_tag_type
isbase64
,base64url
, orbase16
. -
New macro
JSONCONS_TYPE_TRAITS_DECL
that can be used to generate thejson_type_traits
boilerplate for your own types. -
New
basic_json
member functionget_allocator
Bug fix:
Fixed issue wjson dump() not formatting booleans correctly #174
Name change:
- The name
json_staj_reader
has been deprecated and renamed tojson_pull_reader
Bug fix:
- Fixed a bug in json function
empty()
when type isbyte_string
. - Fixed a bug with preserving semantic_tag_type when copying json values of long string type.
Changes:
-
Removed deprecated feature
cbor_view
-
CBOR decimal fraction and bigfloat string formatting now consistent with double string formatting
Enhancements:
-
json
to_string()
andto_double()
now work with CBOR bigfloat -
JSONPath operators in filter expressions now work with
big_integer
,big_decimal
, andbig_float
tagged json values -
json
is_number()
function now returnstrue
if string value is tagged withbig_integer
orbig_decimal
, or if array value is tagged withbig_float
. -
json
as_string()
function now converts arrays tagged withbig_float
to decimal strings -
json
as_double()
function now converts arrays tagged withbig_float
to double values
New features
-
New csv option
lossless_number
. If set totrue
, parse numbers with exponent and fractional parts as strings with semantic taggingsemantic_tag_type::big_decimal
(instead of double.) Defaults tofalse
. -
A class
jsonpointer::address
has been introduced to make it simpler to construct JSON Pointer addresses
Name change
- The
json_options
namedec_to_str
has been deprecated and renamed tolossless_number
.
Deprecated features:
- cbor_view has been deprecated. Rationale: The complexity of supporting and documenting this component exceeded its benefits.
New features
-
New
json_options
optiondec_to_str
. If set totrue
, parse decimal numbers as strings with semantic taggingsemantic_tag_type::big_decimal
instead of double. Defaults tofalse
. -
The
ojson
(order preserving) implementation now has an index to support binary search for retrieval. -
Added
std::string_view
detection -
jsoncons-CBOR semantic tagging supported for CBOR tags 32 (uri)
Name changes (non-breaking)
- The json options name
bignum_chars_format
has been deprecated and replaced withbig_integer_chars_format
. big_integer_chars_format::integer
(bignum_chars_format::integer
) has been deprecated and replaced withbig_integer_chars_format::number
- The
json_options function
bignum_format
has been deprecated and replaced withbig_integer_format
Changes to floating-point printing
-
If the platform supports the IEEE 754 standard, jsoncons now uses the Grisu3 algorithm for printing floating-point numbers, falling back to a safe method using C library functions for the estimated 0.5% of floating-point numbers that might be rejected by Grisu3. The Grisu3 implementation follows Florian Loitsch's grisu3_59_56 implementation. If the platform does not support the IEEE 754 standard, the fall back method is used.
-
In previous versions, jsoncons preserved information about the format, precision, and decimal places of the floating-point numbers that it read, and used that information when printing them. With the current strategy, that information is no longer needed. Consequently, the
floating_point_options
parameter in thedo_double_value
anddouble_value
functions of the SAX-style interface have been removed. -
The
json
functionsprecision()
anddecimal_places()
have been deprecated and return 0 (as this information is no longer preserved.) -
The constructor
json(double val, uint8_t precision)
has been deprecated. -
Note that it is still possible to set precision as a json option when serializing.
New features:
-
New jsonpath functions
keys
andtokenize
. -
jsoncons-CBOR data item mappings supported for CBOR tags 33 (string base64url) and 34 (string base64)
New features:
-
bson UTC datetime associated with jsoncons
semantic_tag_type::timestamp
-
New traits class
is_json_type_traits_impl
that addresses issues #133 and #115 (duplicates) -
Following a proposal from soberich, jsonpath functions on JSONPath expressions are no longer restricted to filter expressions.
-
New jsonpath functions
sum
,count
,avg
, andprod
-
Added
semantic_tag_type::base16
,semantic_tag_type::base64
,semantic_tag_type::base64url
Non-breaking changes:
-
The json constructor that takes a
byte_string
and abyte_string_chars_format
has been deprecated, use asemantic_tag_type
to supply an encoding hint for a byte string, if any. -
The content handler
byte_string_value
function that takes abyte_string
and abyte_string_chars_format
has been deprecated, use asemantic_tag_type
to supply an encoding hint for a byte string, if any.
Changes:
- The
byte_string_chars_format
parameter in the content handlerdo_byte_string_value
function has been removed, thesemantic_tag_type
parameter is now used to supply an encoding hint for a byte string, if any.
Bug fixes:
-
On Windows platforms, fixed issue with macro expansion of max when including windows.h (also in 0.113.1)
-
Fixed compile issue with
j = json::make_array()
(also in 0.113.2)
Breaking changes to jsoncons semantic tag type names:
- semantic_tag_type::bignum to semantic_tag_type::big_integer
- semantic_tag_type::decimal_fraction to semantic_tag_type::big_decimal
- semantic_tag_type::epoch_time to semantic_tag_type::timestamp
Non-breaking name changes:
The following names have been deprecated and renamed (old names still work)
-
bignum_value
tobig_integer_value
injson_content_handler
-
decimal_value
tobig_decimal_value
injson_content_handler
-
epoch_time_value
totimestamp_value
injson_content_handler
-
cbor_bytes_serializer
tocbor_buffer_serializer
-
msgpack_bytes_serializer
tomsgpack_buffer_serializer
-
json_serializing_options
tojson_options
-
csv_serializing_options
tocsv_options
-
parse_error
toserialization_error
The rationale for renaming parse_error
to serialization_error
is that we need to use error category codes for serializer
errors as well as parser errors, so we need a more general name
for the exception type.
Message Pack enhancements
-
New
msgpack_serializer
that supports Message Pack bin formats -
New
msgpack_parser
that supports Message Pack bin formats -
encode_msgpack
anddecode_msgpack
have been rewritten usingmsgpack_serializer
andmsgpack_parser
, and also now support bin formats.
New features:
-
decode from and encode to the Universal Binary JSON Specification (ubjson) data format
-
decode from and encode to the Binary JSON (bson) data format
-
The cbor, msgpack and ubjson streaming serializers now validate that the expected number of items have been supplied in an object or array of pre-determined length.
Bug fix
- Fixed issue with indefinite length byte strings, text strings, arrays, and maps nested inside other CBOR items (wasn't advancing the input pointer past the "break" indicator.)
Changes
-
FILE and LINE macros removed from JSONCONS_ASSERT if not defined _DEBUG (contributed by zhskyy.)
-
semantic_tag_type name
decimal
changed todecimal_fraction
New CBOR feature
-
CBOR semantic tagging of expected conversion of byte strings to base64, base64url and base16 are preserved and respected in JSON serialization (unless overridden in
json_serializing_options
.) -
CBOR semantic tagging of bigfloat preserved with
semantic_tag_type::bigfloat
-
CBOR non text string keys converted to strings when decoding to json values
Changes to json_serializing_options
New options
- spaces_around_colon (defaults to
space_after
) - spaces_around_comma (defaults to
space_after
) - pad_inside_object_braces (defaults to
false
) - pad_inside_array_brackets (defaults to
false
) - line_length_limit (defaults to '120`)
- new_line_chars (for json serialization, defaults to
\n
)
nan_replacement
, pos_inf_replacement
, and neg_inf_replacement
are deprecated (still work)
These have been replaced by
- nan_to_num/nan_to_str
- inf_to_num/inf_to_str
- neginf_to_num/neginf_to_str (default is
-
followed by inf_to_num/inf_to_str)
nan_to_str
, inf_to_str
and neginf_to_str
are also used to substitute back to nan
, inf
and neginf
in the parser.
-
Long since deprecated options
array_array_block_option
,array_object_block_option
,object_object_block_option
andobject_array_block_option
have been removed. -
The names
object_array_split_lines
,object_object_split_lines
,array_array_split_lines
andarray_object_split_lines
have been deprecated (still work) and renamed toobject_array_line_splits
,object_object_line_splits
,array_array_line_splits
andarray_object_line_splits
. Rationale: consistency withline_split_kind
name.
Changes to json_serializer
-
Previously the constructor of
json_serializer
took an optional argument to indicate whether "indenting" was on.json_serializer
now always produces indented output, so this argument has been removed. -
A new class
json_compressed_serializer
produces compressed json without indenting.The jsoncons functions that perform serialization including
json::dump
,pretty_print
and the output stream operator are unaffected.
Changes to json_content_handler
-
The function
byte_string_value
no longer supports passing a byte string ashandler.byte_string_value({'b','a','r'});
(shown in some of the examples.) Instead use
handler.byte_string_value(byte_string({'b','a','r'}));
(or a pointer to utf8_t data and a size.)
- The function
bignum_value
no longer supports passing a CBOR signum and byte string,bignum_value
now accepts only a string view. If you have a CBOR signum and byte string, you can use the bignum class to convert it into a string.
Name changes (non breaking)
-
The name
json_stream_reader
has been deprecated and replaced withjson_staj_reader
. -
The name
stream_event_type
has been deprecated and replaced withstaj_event_type
-
The names
basic_stream_event
(stream_event
) have been deprecated and replaced withbasic_staj_event
(staj_event
) -
The names
basic_stream_filter
(stream_filter
) have been deprecated and replaced withbasic_staj_filter
(staj_filter
) (staj stands for "streaming API for JSON, analagous to StAX in XML) -
The
json_parser
functionend_parse
has been deprecated and replaced withfinish_parse
.
Enhancements
-
json double values convert to CBOR float if double to float round trips.
-
csv_parser
ignore_empty_values
option now applies tom_columns
style json output. -
json_reader and json_staj_reader can be initialized with strings in addition to streams.
Extension of semantic tags to other values
- The `json_content_handler` functions `do_null_value`, `do_bool_value`,
`do_begin_array` and `do_begin_object` have been given the
semantic_tag_type parameter.
- New tag type `semantic_tag_type::undefined` has been added
- The `cbor_parser` encodes a CBOR undefined tag to a json null
value with a `semantic_tag_type::undefined` tag, and the
`cbor_serializer` maps that combination back to a CBOR undefined tag.
Removed:
- Long since deprecated
value()
functions have been removed fromjson_content_handler
Enhancements
-
Improved efficiency of json_decoder
-
Improved efficiency of json_proxy
-
Conversion of CBOR decimal fraction to string uses exponential notation if exponent is positive or if the exponent plus the number of digits in the mantissa is negative.
Bug fix
- Fixed issue with conversion of CBOR decimal fraction to string when mantissa is negative
Bug and warning fixes:
-
A case where the json parser performed validation on a string before all bytes of the string had been read, and failed if missing part of a multi-byte byte sequence, is fixed.
-
An issue with reading a bignum with the pull parser
json_stream_reader
(in the case that an integer value overflows) has been fixed. -
GCC and clang warnings about switch fall through have been fixed
Non-breaking changes:
-
The functions
json::has_key
andcbor::has_key
have been deprecated (but still work) and renamed tojson::contains
andcbor::contains
. Rationale: consistency with C++ 20 associative mapcontains
function. -
The json function
as_integer()
is now a template function,
template <class T = int64_t>
T as_integer();
where T can be any integral type, signed or unsigned. The default parameter is for backwards compatability, but is a depreated feature, and may be removed in a future version. Prefer j.as<int64_t>().
-
The json functions
is_integer()
andis_uinteger()
have been deprecated and renamed tois_int64()
,is_uint64()
. Prefer j.is<int64_t>() and j.is<uint64_t>(). -
The json function
as_uinteger()
has been deprecated. Prefer j.as<uint64_t>().
and as_uinteger()
have been deprecated and renamed to
is_int64()
, is_uint64()
, as_int64()
and as_uint64()
.
Change to pull parser API:
-
The
stream_filter
functionaccept
has been changed to take aconst stream_event&
and aconst serializing_context&
. -
stream_event_type::bignum_value
has been removed.stream_event
now exposes information about optional semantic tagging through thesemantic_tag()
function.
Enhancements:
-
j.as<bignum>()
has been enhanced to return a bignum value if j is an integer, floating point value, or any string that contains an optional minus sign character followed by a sequence of digits. -
j.as<T>()
has been enhanced to support extended integer types that havestd::numeric_limits
specializations. In particular, it supports GCC__int128
andunsigned __int128
when code is compiled withstd=gnu++NN
, allowing abignum
to be returned as an__int128
orunsigned __int128
. (when code is compiled with-std=c++NN
,__int128
andunsigned __int128
do not havestd::numeric_limits
specializations.)
New feature:
This release accomodate the additional semantics for the CBOR data items date-time (a string), and epoch time (a positive or negative integer or floating point value), and decimal fraction (converted in the jsoncons data model to a string).
But first, some of the virtual functions in json_content_handler
have to be modified to preserve these semantics. Consequently,
the function signatures
bool do_int64_value(int64_t, const serializing_context&)
bool do_uint64_value(uint64_t, const serializing_context&)
bool do_double_value(double, const floating_point_options&, const serializing_context&)
bool do_string_value(const string_view_type&, const serializing_context&)
bool do_byte_string_value(const uint8_t*, size_t, const serializing_context&)
have been given an additonal parameter, a semantic_tag_type
,
bool do_int64_value(int64_t, semantic_tag_type, const serializing_context&)
bool do_uint64_value(uint64_t, semantic_tag_type, const serializing_context&)
bool do_double_value(double, const floating_point_options&, semantic_tag_type, const serializing_context&)
bool do_string_value(const string_view_type&, semantic_tag_type, const serializing_context&)
bool do_byte_string_value(const uint8_t*, size_t, semantic_tag_type, const serializing_context&)
For consistency, the virtual function
bool do_bignum_value(const string_view_type&, const serializing_context&)
has been removed, and in its place do_string_value
will be called
with semantic_tag_type::bignum_type.
For users who have written classes that implement all or part of
json_content_handler
, including extensions to json_filter
,
these are breaking changes. But otherwise users should be unaffected.
Continuous integration:
-
jsoncons is now cross compiled for ARMv8-A architecture on Travis using clang and executed using the emulator qemu.
-
UndefinedBehaviorSanitizer (UBSan) is enabled for selected gcc and clang builds.
Maintenance:
- Removed compiler warnings
Bug fixes contributed by Cebtenzzre
-
Fixed a case where
as_double()
,as_integer()
etc on abasic_json
value led to an infinite recursion when the value was a bignum -
Fixed undefined behavior in bignum class
-
A JSON pull parser,
json_stream_reader
, has been added. This required a change to thejson_content_handler
function signatures, the return values has been changed to bool, to indicate whether parsing is to continue. (An earlier version on master was calledjson_event_reader
.) -
json_parser
has new member functionstopped()
. -
The
json::is
function now supportsis<jsoncons::string_view>()
, and if your compiler hasstd::string_view
,is<std::string_view>()
as well. It returnstrue
if the json value is a string, otherwisefalse
. -
The
json::as
function now supportsas<jsoncons::string_view>()
, and if your compiler hasstd::string_view
,as<std::string_view>()
as well.
These changes apply to users that call the public functions defined by
json_content_handler
, e.g. begin_object, end_object, etc., but are
non-breaking because the old function signatures, while deprecated,
have been preserved. Going forward, however, users should remove
calls to begin_document
, replace end_document
with flush
,
and replace integer_value
and end_integer_value
with int64_value
and uint64_value
.
-
The public functions defined by
json_content_handler
have been changed to return a bool value, to indicate whether parsing is to continue. -
The function names
integer_value
anduinteger_value
have been changed toint64_value
anduint64_value
. -
The function names
begin_document
andend_document
have been deprecated. The deprecatedbegin_document
does nothing, and the deprecatedend_document
callsdo_flush
. -
The function
flush
has been added, which callsdo_flush
. -
The
json
member functiondump_fragment
has been deprecated, as with the dropping ofbegin_document
andend_document
, it is now equivalent todump
. -
The function
encode_fragment
has been deprecated, as with the dropping ofbegin_document
andend_document
, it is now equivalent toencode_json
. -
The
json_filter
member functiondownstream_handler
has been renamed todestination_handler
.
These changes will affect users who have written classes that implement
all or part of json_content_handler
, including extensions to json_filter
.
-
The virtual functions defined for
json_content_handler
,do_begin_object
,do_end_object
, etc. have been changed to return a bool value, to indicate whether serializing or deserializing is to continue. -
The virtual functions
do_begin_document
anddo_end_document
have been removed. A virtual functiondo_flush
has been added to allow producers of json events to flush whatever they've buffered. -
The function names
do_integer_value
anddo_uinteger_value
have been changed todo_int64_value
anddo_uint64_value
. -
The signature of
do_bignum_value
has been changed to
bool do_bignum_value(const string_view_type& value,
const serializing_context& context)
Enhancements
- Added byte string formatting option
byte_string_chars_format::base16
Changes
-
Scons dropped as a build system for tests and examples, use CMake
-
Tests no longer depend on boost, boost test framework replaced by Catch2. boost code in tests moved to
examples_boost
directory. -
Previously, if
json_parser
encountered an unopened object or array, e.g. "1]", this would cause a JSONCONS_ASSERT failure, resulting in anstd::runtime_error
. This has been changed to cause ajson_parse_errc::unexpected_right_brace
orjson_parse_errc::unexpected_right_bracket
error code.
Warning fixes
- Eliminated vs2017 level 3 and level 4 warnings
Enhancements
-
bignum_chars_format::base64
is supported -
The incremental parser
json_parser
has been documented
Changes (non-breaking)
-
Previously, jsonpointer::get returned values (copies) Now, jsonpointer::get returns references if applied to
basic_json
, and values if applied tocbor_view
-
bignum_chars_format::string
has been deprecated (still works) and replaced withbignum_chars_format::base10
-
json_parser_errc
,cbor_parser_errc
, andcsv_parser_errc
have been deprecated (still work) and renamed tojson_parse_errc
,cbor_parse_errc
, andcsv_parse_errc
Bug fixes:
- Fixed issue with
UINT_MAX
not declared inbignum.hpp
Bug fixes:
- Fixed issue with cbor_view iterators over indefinite length arrays and maps
Enhancements:
- csv_serializer recognizes byte strings and bignums.
Enhancements
- Support for CBOR bignums
- Added json serializing options for formatting CBOR bignums as integer, string, or base64url encoded byte string
- Added json serializing options for formatting CBOR bytes strings as base64 or base64url
- Enhanced interface for
cbor_view
includingdump
,is<T>
, andas<t>
functions
Changes
-
If the json parser encounters an integer overflow, the value is now handled as a bignum rather than a double value.
-
The
json_content_handler
namesbegin_json
andend_json
have been deprecated and replaced withbegin_document
andend_document
, and the namesdo_begin_json
anddo_end_json
have been removed and replaced withdo_begin_document
, anddo_end_document
. Rationale: meaningfullness across JSON and other data formats including CBOR.
Bug fixes:
- Fixed bug in base64url encoding of CBOR byte strings
- Fixed bug in parsing indefinite length CBOR arrays and maps
Changes
- If a fractional number is read in in fixed format, serialization now preserves that fixed format, e.g. if 0.000071 is read in, serialization gives 0.000071 and not 7.1e-05. In previous versions, the floating point format, whether fixed or scientific, was determined by the behavior of snprintf using the g conversion specifier.
Bug fix:
- Fixed issue with parsing cbor indefinite length arrays and maps
Warning fix:
- Use memcpy in place of reinterpret_cast in binary data format utility
from_big_endian
Compiler fix:
- Fixed issues with g++ 4.8
Enhancements
-
The CSV extension now supports multi-valued fields separated by subfield delimiters
-
New functions
decode_json
andencode_json
convert JSON formatted strings to C++ objects and back. These functions attempt to perform the conversion by streaming usingjson_convert_traits
, and if streaming is not supported, fall back to usingjson_type_traits
.decode_json
andencode_json
will work for all types that havejson_type_traits
defined. -
The json::parse functions and the json_parser and json_reader constructors optionally take a json_serializing_options parameter, which allows replacing a string that matches nan_replacement(), pos_inf_replacement(), and neg_inf_replacement().
Changes to Streaming
-
The
basic_json_input_handler
andbasic_json_output_handler
interfaces have been combined into one classbasic_json_content_handler
. This greatly simplifies the implementation ofbasic_json_filter
. Also, the nameparsing_context
has been deprecated and renamed toserializing_context
, as it now applies to both serializing and deserializing.If you have subclassed
json_filter
or have fed JSON events directlty to ajson_serializer
, you shouldn't have to make any changes. In the less likely case that you've implemented thebasic_json_input_handler
orbasic_json_output_handler
interfaces, you'll need to change that tojson_content_handler
.
Other Changes
-
serialization_traits
and the relateddump
free functions have been deprecated, as their functionality has been subsumed byjson_convert_traits
and theencode_json
functions. -
The option bool argument to indicate pretty printing in the
json
dump
functions and thejson_serializer
class has been deprecated. It is replaced by the enum classindenting
with enumeratorsindenting::no_indent
andindenting::indent
. -
The name
serialization_options
has been deprecated (still works) and renamed tojson_serializing_options
. Rationale: naming consistency. -
The
json_reader
max_nesting_depth
getter and setter functions have been deprecated. Use thejson_serializing_options
max_nesting_depth
getter and setter functions instead. -
The name
csv_parameters
has been deprecated (still works) and renamed tocsv_serializing_options
. Rationale: naming consistency.
Changes
decode_csv
by default now attempts to infer null, true, false, integer and floating point values in the CSV source. In previous versions the default was to read everything as strings, and other types had to be specified explicitly. If the new default behavior is not desired, thecsv_parameters
optioninfer_types
can be set tofalse
. Column types can still be set explicitly if desired.
Changes
-
Default
string_view_type
operator std::basic_string<CharT,Traits,Allocator>() const
made explicit to be consistent withstd::string_view
-
The virtual method
do_double_value
ofjson_input_handler
andjson_output_handler
takes anumber_format
parameter
Performance improvements
- Faster json dump to string (avoids streams)
- Faster floating point conversions for linux and MacOSX
- Memory allocation decoding larger string values reduced by half
- Optimization to json_parser parse_string
- Improvements to json_decoder
Bug fix:
Fixed an off-by-one error that could lead to an out of bounds read. Reported by mickcollyer (issue #145)
Bug fixes:
Fixed issue with how jsonpath filters are applied to arrays in the presence of recursion, resulting in duplicate results.
Changes:
The signatures of jsonpointer::get
, jsonpointer::insert
, jsonpointer::insert_or_assign
,
jsonpointer::remove
and jsonpointer::replace
have been changed to be consistent
with other functions in the jsoncons library. Each of these functions now has two overloads,
one that takes an std::error_code
parameter and uses it to report errors, and one that
throws a jsonpointer_error
exception to report errors.
The function jsonpatch::patch
has been replaced by jsonpatch::apply_patch
, which takes
a json document, a patch, and a std::error_code&
to report errors. The function
jsonpatch::diff
has been renamed to jsonpatch::from_diff
The old signatures for encode_cbor
and encode_msgpack
that returned a std::vector<uint8_t>
have been deprecated and replaced by new signatures that have void return values and have
an output parameter 'std::vector<uint8_t>&'. The rationale for this change is consistency
with other functions in the jsoncons library.
Fixes:
- Fixes to
string_view
code whenJSONCONS_HAS_STRING_VIEW
is defined injsoncons_config.hpp
Changes:
as_double
throws ifjson
value is null (previously returned NaN)
Enhancements:
- Added convenience functions
decode_csv
andencode_csv
- Support custom allocaor (currently stateless only) in
json_decoder
,json_reader
,csv_reader
,csv_parameters
Resolved warnings on GCC Issue #127
Fix for platform issue with vs2017:
- Renamed label
minus
tominus_sign
injson_parser.hpp
Enhancements:
- New classes
byte_string
andbyte_string_view
, to augment support for cbor byte strings injson
values
Changes:
-
template <class CharT> json_traits<CharT>
replaced withsorted_policy
-
template <class CharT> o_json_traits<CharT>
replaced withpreserve_order_policy
-
The return type for the json::get_with_default function overload for
const char*
has been changed fromconst char*
tojson::string_view_type
, which is assignable tostd::string
. -
New functions
byte_string_value
anddo_byte_string_value
have been added tobasic_json_input_handler
andbasic_json_output_handler
-
json::is<const char*>() and json::as<const char*>() specializations (supported but never documented) have been deprecated
-
In android specific
string_to_double
,strtod_l
changed tostrtold_l
Enhancements:
-
The
json
class and thedecode_cbor
andencode_cbor
functions now support byte strings Ajson
byte string value will, when serialized to JSON, be converted to a base64url string. -
version.hpp
added toinclude
directory
Bug fixes:
- Fixed issue with jsonpatch::diff (fix contributed by Alexander (rog13))
Enhancements:
- New class
cbor_view
for accessing packedcbor
values. Acbor_view
satisfies the requirements forjsonpointer::get
.
jsonpointer::erase
renamed tojsonpointer::remove
, old name deprecated
-
JSON Pointer implementation
-
JSON Patch implementation, includes patch and diff
-
json::insert
function for array that inserts values from range [first, last) before pos.
Bug fixes
- Fixed issue with serialization of json array of objects to csv file
-
The member function name
json::dump_body
has been deprecated and replaced withjson::dump_fragment
. -
The non member function name
dump_body
has been deprecated and replaced withdump_fragment
. -
The class name
rename_name_filter
has been deprecated and replaced withrename_object_member_filter
. -
In the documentation and examples, the existing function
json::insert_or_assign
is now used instead of the still-supportedjson::set
. The reason is thatinsert_or_assign
follows the naming convention of the C++ standard library.
-
The recently introduced class
json_stream_traits
has been renamed toserialization_traits
-
Removed template parameter
CharT
from classbasic_parsing_context
and renamed it toparsing_context
-
Removed template parameter
CharT
from classbasic_parse_error_handler
and renamed it toparse_error_handler
New features
- Added
json
functionspush_back
andinsert
for appending values to the end of ajson
array and inserting values at a specifed position
Rationale: While these functions provide the same functionality as the existing
json::add
function, they have the advantage of following the naming conventions
of the C++ library, and have been given prominence in the examples and documentation
(add
is still supported.)
New features
-
cbor extension supports encoding to and decoding from the cbor binary serialization format.
-
json_type_traits
supportsstd::valarray
Documentation
- Documentation is now in the repository itself. Please see the documentation link in the README.md file
Changed
- Removed
CharT
template parameter fromjson_stream_traits
Changes
-
Visual Studio 2013 is no longer supported (jsonpath uses string initilizer lists)
-
json_input_handler
overloaded functions value(value,context)have been deprecated. Instead use
string_value(value,context),
integer_value(value,context),
uinteger_value(value,context),
double_value(value,precision,context),
bool_value(value,context)and
null_value(context)` -
json_output_handler
overloaded functions value(value)have been deprecated. Instead use
string_value(value),
integer_value(value),
uinteger_value(value),
double_value(value,precision=0),
bool_value(value)and
null_value(context)` -
For consistency, the names
jsoncons_ext/msgpack/message_pack.hpp
,encode_message_pack
anddecode_message_pack
have been deprecated and replaced withjsoncons_ext/msgpack/msgpack.hpp
,encode_msgpack
anddecode_msg_pack
Bug fixes
-
Fixed operator== throws when comparing a string against an empty object
-
Fixed jsonpath issue with array 'length' (a.length worked but not a['length'])
-
msgpack
extension uses intrinsics for determing whether to swap bytes
New features
-
Stream supported C++ values directly to JSON output, governed by
json_stream_traits
-
json::is() and json::as() accept template packs, which they forward to the
json_type_traits
is
andas
functions. This allows user definedjson_type_traits
implementations to resolve, for instance, a name into a C++ object looked up from a registry. See Type Extensibility, Example 2. -
jsonpath
json_query
now supports returning normalized paths (with optionalreturn_type::path
parameter) -
New jsonpath
max
andmin
aggregate functions over numeric values -
New
json::merge
function that inserts another json object's key-value pairs into a json object, if they don't already exist. -
New
json::merge_or_update
function that inserts another json object's key-value pairs into a json object, or assigns them if they already exist.
-
json_type_traits
supportsstd::pair
(convert to/from json array of size 2) -
parse_stream
renamed toparse
(backwards compatible) -
kvp_type
renamed tokey_value_pair_type
(backwards compatible) -
The
_json
and_ojson
literal operators have been moved to the namespacejsoncons::literals
. Access to these literals now requires
using namespace jsoncons::literals;
Rationale: avoid name clashes with other json
libraries
-
The name
owjson
has been deprecated (still works) and changed towojson
. Rationale: naming consistency -
Added json array functions
emplace_back
andemplace
, and json object functionstry_emplace
andinsert_or_assign
, which are analagous to the standard library vector and map functions.
Bug fix
- A bug was introduced in 0.99.7 causing the values of existing object members to not be changed wiht set or assignment operations. This has been fixed.
Change
- jsoncons_ext/binary changed to jsoncons_ext/msgpack
- namespace jsoncons::binary changed to jsoncons::msgpack
- Workarounds in unicode_traits and jsonpath to maintain support for vs2013
- Added
mapping_type::n_rows
,mapping_type::n_objects
, andmapping_type::m_columns
options for csv to json
Bug fixes
- Issues with precedence in JsonPath filter evaluations have been fixed
- An issue with (a - expression) in JsonPath filter evaluations has been fixed
New feature
- The new binary extension supports encoding to and decoding from the MessagePack binary serialization format.
- An extension to JsonPath to allow filter expressions over a single object.
- Added support for
*
and/
operators to jsonpath filter - literal operators _json and _ojson have been introduced
Non-breaking changes
- The
json
write
functions have been renamed todump
. The old names have been deprecated but still work. - Support for stateful allocators
- json function object_range() now returns a pair of RandomAccessIterator (previously BidirectionalIterator)
- json operator [size_t i] applied to a json object now returns the ith object (previously threw)
Breaking change (if you've implemented your own input and output handlers)
In basic_json_input_handler, the virtual functions
virtual void do_name(const CharT* value, size_t length,
const basic_parsing_context<CharT>& context)
virtual void do_string_value(const CharT* value, size_t length,
const basic_parsing_context<CharT>& context)
have been changed to
virtual void do_name(string_view_type val,
const basic_parsing_context<CharT>& context)
virtual void do_string_value(string_view_type val,
const basic_parsing_context<CharT>& context)
In basic_json_output_handler, the virtual functions
virtual void do_name(const CharT* value, size_t length)
virtual void do_string_value(const CharT* value, size_t length)
have been changed to
virtual void do_name(string_view_type val)
virtual void do_string_value(string_view_type val)
Removed features:
- The jsonx extension has been removed
- Validations added to utf8 and utf16 string parsing to pass all JSONTestSuite tests
- The name
json_encoder
introduced in 0.99.4 has been changed tojson_decoder
. Rationale: consistencty with common usage (encoding and serialization, decoding and deserialization)
Fixes Issue #101, In json.hpp, line 3376 change "char__type" to "char_type" Fixes Issue #102, include cstring and json_error_category.hpp in json.hpp
Changes
- The deprecated class
json::any
has been removed. - The jsoncons
boost
extension has been removed. That extension contained a samplejson_type_traits
specialization forboost::gregorian::date
, which may still be found in the "Type Extensibility" tutorial. - The member
json_type_traits
member functionassign
has been removed and replaced byto_json
. if you have implemented your own type specializations, you will also have to change yourassign
function toto_json
. json_type_traits
specializations no longer require theis_assignable
data member
Non-breaking name changes
- The names
json_deserializer
,ojson_deserializer
,wjson_deserializer
,owjson_deserializer
have been deprecated (they still work) and replaced byjson_encoder<json>
,json_encoder<ojson>
,json_encoder<wjson>
andjson_encoder<owjson>
. - The name
output_format
has been deprecated (still works) and renamed toserialization_options
. - The name
wojson
has been deprecated (still works) and renamed toowjson
. - The
json_filter
member functioninput_handler
has been deprecated (still works) and renamed todownstream_handler
. - The name
elements
has been deprecated (still works) and renamed toowjson
. - The
json
member functionmembers()
has been deprecated (still works) and renamed toobject_range()
. - The
json
member functionelements()
has been deprecated (still works) and renamed toarray_range()
. - The
json
member_type functionname()
has been deprecated (still works) and renamed tokey()
. Rationale: consistency with more general underlying storage classes.
New features
json_filter
instances can be passed to functions that take ajson_output_handler
argument (previously only ajson_input_handler
argument)- New
jsonpath
functionjson_replace
that searches for all values that match a JsonPath expression and replaces them with a specified value. json
class has new methodhas_key()
, which returnstrue
if ajson
value is an object and has a member with that key- New filter class
rename_name
allows search and replace of JSON object names
Changes
The json
initializer-list constructor has been removed, it gives inconsistent results when an initializer has zero elements, or one element of the type being initialized (json
). Please replace
json j = {1,2,3}
with json j = json::array{1,2,3}
, and
json j = {{1,2,3},{4,5,6}}
with json j = json::array{json::array{1,2,3},json::array{4,5,6}}
- Initializer-list constructors are now supported in
json::object
as well asjson::array
, e.g.
json j = json::object{{"first",1},{"second",json::array{1,2,3}}};
-
json::any has been deprecated and will be removed in the future
-
The json method
to_stream
has been renamed towrite
, the old name is still supported. -
output_format
object_array_block_option
,array_array_block_option
functions have been deprecated and replaced byobject_array_split_lines
,array_array_split_lines
functions.
Enhancements
-
A new method
get_with_default
, with return type that of the default, has been added tojson
-
A new template parameter,
JsonTraits
, has been added to thebasic_json
class template. -
New instantiations of
basic_json
,ojson
andwojson
, have been added for users who wish to preserve the alphabetical sort of parsed json text and to insert new members in arbitrary name order. -
Added support for
json
is<T>
,as<T>
, constructor, and assignment operator for any sequence container (std::array
,std::vector
,std::deque
,std::forward_list
,std::list
) whose values are assignable to JSON types (e.g., ints, doubles, bools, strings, STL containers of same) and for associative containers (std::set
,std::multiset
,std::unordered_set
,std::unordered_multiset
.) -
Added static method
null()
tojson
class to return null value -
A new extension jsonx that supports serializing JSON values to JSONx (XML)
-
json parser will skip
bom
in input if present
Fixes:
-
Fixes to the
jsonpath
extension, including the union operator and applying index operations to string values -
Fixes to remove warnings and issues reported by VS2015 with 4-th warnings level, PVS-Studio static analyzer tool, and UBSAN.
-
Included workaround for a C++11 issue in GCC 4.8, contributed by Alex Merry
-
Fixed operator== so that json() == json(json::object())
-
Fixed issue with
json
assignment to initializer list -
Fixed issue with assignment to empty json object with multiple keys, e.g.
json val; val["key1"]["key2"] = 1;
- Fix to json_filter class
- Fix to readme_examples
- Fixes to deprecated json parse functions (deprecated, but still supposed to work)
- The Visual C++ specific implementation for reading floating point numbers should have freed a
_locale_t
object, fixed - Added
json_type_traits
specialization to support assignment from non-const strings - When parsing fractional numbers in text, floating point number precision is retained, and made available to serialization to preserve round-trip. The default output precision has been changed from 15 to 16.
- Added json
std::initializer_list
constructor for constructing arrays - The deprecated json member constants null, an_object, and an_array have been removed
- Microsoft VC++ versions earlier than 2013 are no longer supported
- Fixes issues with compilation with clang
New features
- Supports Stefan Goessner's JsonPath.
- json member function
find
added - json member function
count
added - json array range accessor
elements()
added, which supports range-based for loops over json arrays, and replacesbegin_elements
andend_elements
- json object range accessor
members()
added, which supports range-based for loops over json objects, and replacesbegin_members
andend_members
- New version of json
add
member function that takes a parameterarray_iterator
- json member function
shrink_to_fit
added
API Changes
-
The json internal representation of signed and unsigned integers has been changed from
long long
andunsigned long long
toint64_t
anduint64_t
. This should not impact you unless you've implemented your ownjson_input_handler
orjson_output_handler
, in which case you'll need to change yourjson_input_handler
function signaturesvoid do_longlong_value(long long value, const basic_parsing_context& context) override void do_ulonglong_integer_value(unsigned long long value, const basic_parsing_context& context) override
to
void do_integer_value(int64_t value, const basic_parsing_context<Char>& context) override
void do_uinteger_value(uint64_t value, const basic_parsing_context<Char>& context) override
and your json_output_handler
function signatures from
void do_longlong_value(long long value) override
void do_ulonglong_integer_value(unsigned long long value) override
to
void do_integer_value(int64_t value) override
void do_uinteger_value(uint64_t value) override
output_format
drops support forfloatfield
property
Non-beaking API Changes
- remove_range has been deprecated, use erase(array_iterator first, array_iterator last) instead
- remove has been deprecated, use erase(const std::string& name ) instead
json::parse_string
has been renamed tojson::parse
,parse_string
is deprecated but still worksjson member function
is_emptyhas been renamed to
empty,
is_empty` is deprecated but still works. Rationale: consistency with C++ containers- json member functions
begin_elements
andend_elements
have been deprecated, instead useelements().begin()
andelements.end()
- json member functions
begin_members
andend_members
have been deprecated, instead usemembers().begin()
andmembers.end()
- json member function
has_member
has been deprecated, instead usecount
. Rationale: consistency with C++ containers - json member function
remove_member
has been deprecated, instead useremove
. Rationale: only member function left with _element or _member suffix - json_parse_exception renamed to parse_error, json_parse_exception typedef to parse_error
- json::parse(std::istream& is) renamed to json::parse_stream. json::parse(std::istream is) is deprecated but still works.
json
constructor is now templated, so constructors now accept extended types- Following RFC7159,
json_parser
now accepts any JSON value, removing the constraint that it be an object or array. - The member
json_type_traits
member functionsis
,as
, andassign
have been changed to static functions. if you have implemented your own type specializations, you will also have to change youris
,as
andassign
functions to be static. - Removed json deprecated functions
custom_data
,set_custom_data
,add_custom_data
json_reader
member functionmax_depth
has been renamed tomax_nesting_depth
, the former name is still supported.json
member functionresize_array
has been renamed toresize
, the former name is still supported.
jsoncons supports alternative ways for constructing null
, object
, and array
values.
null:
json a = jsoncons::null_type(); // Using type constructor
json b = json::null_type(); // Using alias
json c(json::null); // From static data member prototype
object:
json a(); // Default is empty object
json b = json::object(); // Using type constructor
json c(json::an_object); // From static data member prototype
array:
json a = json::array(); // Using type constructor
json b = json::make_array(); // Using factory method
json c(json::an_array); // From static data member prototype
Since C++ has possible order issues with static data members, the jsoncons examples and documentation have been changed to consistently use the other ways, and json::null
, json::an_object
and json::an_array
have been, while still usable, deprecated.
- Enhances parser for CSV files that outputs JSON, see example below.
- Adds
get_result
member function tojson_deserializer
, which returns the json valuev
stored in ajson_deserializer
asstd::move(v)
. Theroot()
member function has been deprecated but is still supported. - Adds
is_valid
member function tojson_deserializer
- Enhances json::any class, adds type checks when casting back to original value
- Fixes some warning messages
Bug fixes:
- Fixes the noexcept specification (required for Visual Studio 2015 and later.) Fix contributed by Rupert Steel.
- Fixes bug with proxy operator== when comparing object member values, such as in val["field"] == json("abc")
Enhancements:
-
Refines error codes and improves error messages
-
Renames
json_reader
methodread
toread_next
, reflecting the fact that it supports reading a sequence of JSON texts from a stream. The former name is deprecated but still works. -
Adds
json_reader
methodcheck_done
that throws if there are unconsumed non-whitespace characters after one or more calls toread_next
. -
Adds getter and setter
max_depth
methods to allow setting the maximum JSON parse tree depth if desired, by default it is arbitrarily large (limited by heap memory.) -
Modifies
json
static methodsparse_string
,parse_file
, andparse
behaviour to throw if there are unconsumed non-whitespace characters after reading one JSON text.
Changes to extensions:
- Changes the top level namespace for the extensions from
jsoncons_ext
tojsoncons
, e.g.jsoncons_ext::csv::csv_reader
becomesjsoncons::csv::csv_reader
- Modifies csv_reader and csv_serializer so that the constructors are passed parameters in a
csv_parameters
object rather than ajson
object. - Adds more options to csv_reader
-
Incorporates test suite files from http://www.json.org/JSON_checker/ into test suite
-
The
jsoncons
parser accepts all of the JSON_checker files that its supposed to accept. -
Failures to reject incorrect exponential notation (e.g. [0e+-1]) have been fixed.
-
The
jsoncons
parser now rejects all of the JSON_checker files that its supposed to reject except ones with stuff after the end of the document, e.g.["Extra close"]]
(Currently the
jsoncons
parser stops after reading a complete JSON text, and supports reading a sequence of JSON texts.) -
Incorporates a fix to operator== on json objects, contributed by Alex Merry
- "Transforming JSON with filters" example fixed
- Added a class-specific in-place new to the json class that is implemented in terms of the global version (required to create json objects with placement new operator.)
- Reorganized header files, removing unnecessary includes.
- Incorporates validation contributed by Alex Merry for ensuring that there is an object or array on parse head.
- Incorporates fix contributed by Milan Burda for �Switch case is in protected scope� clang build error
- Reversion of 0.96 change:
The virtual methods do_float_value
, do_integer_value
, and do_unsigned_value
of json_input_handler
and json_output_handler
have been restored to do_double_value
, do_longlong_value
and do_ulonglong_value
, and their typedefed parameter types float_type
, integer_type
, and unsigned_type
have been restored to double
, long long
, and unsigned long long
.
The rationale for this reversion is that the change doesn't really help to make the software more flexible, and that it's better to leave out the typedefs. There will be future enhancements to support greater numeric precision, but these will not affect the current method signatures.
- Fix for "unused variable" warning message
This release includes breaking changes to interfaces. Going forward, the interfaces are expected to be stable.
Breaking changes:
-
Renamed
error_handler
toparse_error_handler
. -
Renamed namespace
json_parser_error
tojson_parser_errc
-
Renamed
value_adapter
tojson_type_traits
, if you have implemented your own type specializations, you will have to renamevalue_adapter
also. -
Only json arrays now support
operator[](size_t)
to loop over values, this is no longer supported forjson
objects. Use a json object iterator instead. -
The virtual methods
do_double_value
,do_integer_value
anddo_uinteger_value
ofjson_input_handler
andjson_output_handler
have been renamed todo_float_value
,do_integer_value
, anddo_unsigned_value
, and their parameters have been changed fromdouble
,long long
, andunsigned long long
to typedefsfloat_type
,integer_type
, andunsigned_type
. The rationale for this change is to allow different configurations for internal number types (reversed in 0.97.)
General changes
-
json
member functionbegin_object
now returns a bidirectional iterator rather than a random access iterator. -
Static singleton
instance
methods have been added todefault_parse_error_handler
andempty_json_input_handler
. -
Added to the
json
class overloaded static methods parse, parse_string and parse_file that take aparse_error_handler
as a parameter. -
Added methods
last_char()
andeof()
toparsing_context
. -
Enhancements to json parsing and json parse event error notification.
-
Added to
json_input_handler
andjson_output_handler
a non virtual methodvalue
that takes a null terminated string. -
Added methods
is_integer
,is_unsigned
andis_float
tojson
to replaceis_longlong
,is_ulonglong
andis_double
, which have been deprecated. -
Added methods
as_integer
,as_unsigned
andas_float
tojson
to replaceis_longlong
,is_ulonglong
andis_double
, which have been deprecated.
Bug fixes:
-
Fixed issue with column number reported by json_reader
-
Where &s[0] and s.length() were passed to methods, &s[0] has been replaced with s.c_str(). While this shouldn't be an issue on most implementations, VS throws an exception in debug modes when the string has length zero.
-
Fixes two issues in 0.95 reported by Alex Merry that caused errors with GCC: a superfluous typename has been removed in csv_serializer.hpp, and a JSONCONS_NOEXCEPT specifier has been added to the json_error_category_impl name method.
-
Fixed a number of typename issues in the 0.96 candidate identifed by Ignatov Serguei.
-
Fixes issues with testsuite cmake and scons reported by Alex Merry and Ignatov Serguei
Enhancements:
-
Added template method
any_cast
tojson
class. -
The allocator type parameter in basic_json is now supported, it allows you to supply a custom allocator for dynamically allocated, fixed size small objects in the json container. The allocator type is not used for structures including vectors and strings that use large or variable amounts of memory, these always use the default allocators.
Non-breaking Change:
json_filter
methodparent
has been renamed toinput_handler
(old name still works)
Breaking change (if you've implemented your own input and output handlers, or if you've passed json events to input and output handlers directly):
-
The input handler virtual method
name(const std::string& name, const parsing_context& context)
has been changed todo_name(const char* p, size_t length, const parsing_context& context)
-
The output handler virtual method
name(const std::string& name)
has been changed todo_name(const char* p, size_t length)
-
The input handler virtual method
string_value(const std::string& value, const parsing_context& context)
has been changed todo_string_value(const char* p, size_t length, const parsing_context& context)
-
The output handler virtual method
string_value(const std::string& value)
has been changed todo_string_value(const char* p, size_t length)
The rationale for the method parameter changes is to allow different internal representations of strings but preserve efficiency.
-
The input and output handler virtual implementation methods begin_json, end_json, begin_object, end_object, begin_array, end_array, name, string_value, longlong_value, ulonglong_value, double_value, bool_value and null_value have been renamed to do_begin_json, do_end_json, do_begin_object, do_end_object, do_begin_array, do_end_array, do_name, do_string_value, do_longlong_value, do_ulonglong_value, do_double_value, do_bool_value and do_null_value and have been made private.
-
Public non-virtual interface methods begin_json, end_json, begin_object, end_object, begin_array, end_array, name have been added to json_input_handler and json_output_handler.
The rationale for these changes is to follow best C++ practices by making the json_input_handler and json_output_handler interfaces public non-virtual and the implementations private virtual. Refer to the documentation and tutorials for details.
- The error_handler virtual implementation methods have been renamed to
do_warning
anddo_error
, and made private. Non virtual public interface methodswarning
anderror
have been added. Error handling now leveragesstd::error_code
to communicate parser error events in an extendable way.
Bug fixes:
- Fixed bug in csv_reader
Bug fixes:
- Incorporates fix from Alex Merry for comparison of json objects
Bug fixes
- Incorporates contributions from Cory Fields for silencing some compiler warnings
- Fixes bug reported by Vitaliy Gusev in json object operator[size_t]
- Fixes bug in json is_empty method for empty objects
Changes
- json constructors that take string, double etc. are now declared explicit (assignments and defaults to get and make_array methods have their own implementation and do not depend on implicit constructors.)
- make_multi_array renamed to make_array (old name is still supported)
- Previous versions supported any type values through special methods set_custom_data, add_custom_data, and custom_data. This version introduces a new type json::any that wraps any values and works with the usual accessors set, add and as, so the specialized methods are no longer required.
Enhancements
- json get method with default value now accepts extended types as defaults
- json make_array method with default value now accepts extended types as defaults
New extensions
- Added jsoncons_ext/boost/type_extensions.hpp to collect extensions traits for boost types, in particular, for boost::gregorian dates.
New features
- Supports wide character strings and streams with wjson, wjson_reader etc. Assumes UTF16 encoding if sizeof(wchar_t)=2 and UTF32 encoding if sizeof(wchar_t)=4.
- The empty class null_type is added to the jsoncons namespace, it replaces the member type json::null_type (json::null_type is typedefed to jsoncons::null_type for backward compatibility.)
Defect fixes:
- The ascii character 0x7f (del) was not being considered a control character to be escaped, this is fixed.
- Fixed two issues with serialization when the output format property escape_all_non_ascii is enabled. One, the individual bytes were being checked if they were non ascii, rather than first converting to a codepoint. Two, continuations weren't being handled when decoding.
Includes contributed updates for valid compilation and execution in gcc and clang environments
Breaking change (but only if you have subclassed json_input_handler or json_output_handler)
- For consistency with other names, the input and output handler methods new to 0.91 - value_string, value_double, value_longlong, value_ulonglong and value_bool - have been renamed to string_value, double_value, longlong_value, ulonglong_value and bool_value.
Non breaking changes (previous features are deprecated but still work)
-
name_value_pair has been renamed to member_type (typedefed to previous name.)
-
as_string(output_format format) has been deprecated, use the existing to_string(output_format format) instead
Enhancements:
- json now has extensibilty, you can access and modify json values with new types, see the tutorial Extensibility
Preparation for allocator support:
- The basic_json and related classes now have an Storage template parameter, which is currently just a placeholder, but will later provide a hook to allow users to control how json storage is allocated. This addition is transparent to users of the json and related classes.
This release should be largely backwards compatible with 0.90 and 0.83 with two exceptions:
-
If you have used object iterators, you will need to replace uses of std::pair with name_value_pair, in particular, first becomes name() and second becomes value().
-
If you have subclassed json_input_handler, json_output_handler, or json_filter, and have implemented value(const std::string& ..., value(double ..., etc., you will need to modify the names to value_string(const std::string& ..., value_double(double ... (no changes if you are feeding existing implementations.)
The changes are
-
Replaced std::pairstd::string,json with name_value_pair that has accessors name() and value()
-
In json_input_handler and json_output_handler, allowed for overrides of the value methods by making them non-virtual and adding virtual methods value_string, value_double, value_longlong, value_ulonglong, and value_bool
Other new features:
-
Changed implementation of is and as, the current implementation should be user extensible
-
make_multi_array makes a multidimensional array with the number of dimensions specified as a template parameter. Replaces make_2d_array and make_3d_array, which are now deprecated.
-
Added support for is<std::vector> and as<std::vector>
-
Removed JSONCONS_NO_CXX11_RVALUE_REFERENCES, compiler must support move semantics
Incorporates a number of contributions from Pedro Larroy and the developers of the clearskies_core project:
- build system for posix systems
- GCC to list of supported compilers
- Android fix
- fixed virtual destructors missing in json_input_handler, json_output_handler and parsing_context
- fixed const_iterator should be iterator in json_object implementation
To clean up the interface and avoid too much duplicated functionality, we've deprecated some json methods (but they still work)
make_array
Use json val(json::an_array) or json::make_multi_array<1>(...) instead (but make_array will continue to work)
make_2d_array
make_3d_array
Use make_multi_array<2> and make_multi_array<3> instead
as_vector
Use as<std::vector> etc. instead
as_int
as_uint
as_char
Use as, as, and as instead
Fixed issue affecting clang compile
This release should be fully backwards compatible with 0.83.
Includes performance enhancements to json_reader and json_deserializer
Fixes issues with column numbers reported with exceptions
Incorporates a number of patches contributed by Marc Chevrier:
- Fixed issue with set member on json object when a member with that name already exists
- clang port
- cmake build files for examples and test suite
- json template method is for examining the types of json values
- json template method as for accessing json values
Optimizations (very unlikely to break earlier code)
-
get(const std::name& name) const now returns const json& if keyed value exists, otherwise a const reference to json::null
-
get(const std::string& name, const json& default_val) const now returns const json (actually a const proxy that evaluates to json if read)
Bug fixes
- Line number not incremented within multiline comment - fixed
Deprecated features removed
- Removed deprecated output_format properties (too much bagage to carry around)
-
The const version of the json operator[](const std::string& name) didn't need to return a proxy, the return value has been changed to const json& (this change is transparent to the user.)
-
get(const std::name& name) has been changed to return a copy (rather than a reference), and json::null if there is no member with that name (rather than throw.) This way both get methods return default values if no keyed value exists.
-
non-const and const methods json& at(const std::name& name) have been added to replace the old single argument get method. These have the same behavior as the corresponding operator[] functions, but the non-const at is more efficient.
-
Added accessor and modifier methods floatfield to output_format to provide a supported way to set the floatfield format flag to fixed or scientific with a specified number of decimal places (this can be done in older versions, but only with deprecated methods.)
-
The default constructor now constructs an empty object (rather than a null object.) While this is a change, it's unlikely to break exisitng code (all test cases passed without modification.)
This means that instead of
json obj(json::an_object);
obj["field"] = "field";
you can simply write
json obj;
obj["field"] = "field";
The former notation is still supported, though.
-
Added a version of 'resize_array' to json that resizes the array to n elements and initializes them to a specified value.
-
Added a version of the static method json::make_array that takes no arguments and makes an empty json array
Note that
json arr(json::an_array);
is equivalent to
json arr = json::make_array();
and
json arr(json::an_array);
arr.resize_array(10,0.0);
is equivalent to
json arr = json::make_array(10,0.0);
For consistency the json::make_array notation is now favored in the documentation.
-
Added resize_array method to json for resizing json arrays
-
Fixed issue with remove_range method (templated code failed to compile if calling this method.)
-
Added remove_member method to remove a member from a json object
-
Fixed issue with multiline line comments, added test case
-
Fixed issue with adding custom data to a json array using add_custom_data, added examples.
-
Since 0.50, jsoncons has used snprintf for default serialization of double values to string values. This can result in invalid json output when running on a locale like German or Spanish. The period character (�.�) is now always used as the decimal point, non English locales are ignored.
-
The output_format methods that support alternative floating point formatting, e.g. fixed, have been deprecated.
-
Added a template method as_vector to the json class. If a json value is an array and conversion is possible to the template type, returns a std::vector of that type, otherwise throws an std::exception. Specializations are provided for std::string, bool, char, int, unsigned int, long, unsigned long, long long, unsigned long long, and double. For example
std::string s("[0,1,2,3]");
json val = json::parse_string(s);
std::vector v = val.as_vector();
-
Undeprecated the json member function precision
This release (0.60b) is fully backwards compatible with 0.50.
A change introduced with 0.60 has been reversed. 0.60 introduced an alternative method of constructing a json arrray or object with an initial default constructor, a bug with this was fixed in 0.60a, but this feature and related documentation has been removed because it added complexity but no real value.
-
Added swap member function to json
-
Added add and add_custom_data overrides to json that take an index value, for adding a new element at the specified index and shifting all elements currently at or above that index to the right.
-
Added capacity member functions to json
- csv_serializer has been added to the csv extension
This release is fully backwards compatible with 0.4*, and mostly backwards compatible to 0.32 apart from the two name changes in 0.41
Bug fixes
- When reading the escaped characters "\b", "\f", "\r" and "\t" appearing in json strings, json_reader was replacing them with the linefeed character, this has been fixed.
Deprecated
- Deprecated modifiers precision and fixed_decimal_places from output_format. Use set_floating_point_format instead.
- Deprecated constructor that takes indenting parameter from output_format. For pretty printing with indenting, use the pretty_print function or pass the indenting parameter in json_serializer.
Changes
- When serializing floating point values to a stream, previous versions defaulted to default floating point precision with a precision of 16. This has been changed to truncate trailing zeros but keep one if immediately after a decimal point.
New features
- For line reporting in parser error messages, json_reader now recognizes \r\n, \n alone or \r alone (\r alone is new.)
- Added set_floating_point_format methods to output_format to give more control over floating point notation.
Non functional enhancements
- json_reader now estimates the minimum capacity for arrays and objects, and reports that information for the begin_array and begin_object events. This greatly reduces reallocations.
- Fixed another bug with multi line /**/ comments
- Minor fixes to reporting line and column number of errors
- Added fixed_decimal_places setter to output_format
- Added version of as_string to json that takes output_format as a parameter
- Reorganization of test cases and examples in source tree
- Added non-member overload swap(json& a, json& b)
- Fixed bug with multi line /**/ comments
- Added begin_json and end_json methods to json_output_handler
- json_deserializer should now satisfy basic exception safety (no leak guarantee)
- Moved csv_reader.hpp to jsoncons_ext/csv directory
- Changed csv_reader namespace to jsoncons::csv
- json::parse_file no longer reads the entire file into memory before parsing (it now uses json_reader default buffering)
-
json_listener renamed to json_input_handler
-
json_writer renamed to json_output_handler
-
Added json_filter class
-
json get method that takes default argument now returns a value rather than a reference
-
Issue in csv_reader related to get method issue fixed
-
Issue with const json operator[] fixed
-
Added as_char method to json
-
Improved exception safety, some opportunites for memory leaks in the presence of exceptions removed
Added reserve method to json
Added static make_3d_array method to json
json_reader now configured for buffered reading
Added csv_reader class for reading CSV files and producing JSON events
Fixed bug with explicitly passing output_format in pretty_print.
Added remove_range method, operator== and operator!= to proxy and json objects
Added static methods make_array and make_2d_array to json
error_handler method content_error renamed to error
Added error_code to warning, error and fatal_error methods of error_handler
json_in_stream renamed to json_listener
json_out_stream renamed to json_writer
Added buffer accessor method to parsing_context
Added parsing_context class for providing information about the element being parsed.
error_handler methods take message and parsing_context parameters
json_in_stream handlers take parsing_context parameter
Added error_handler class for json_reader
Made json_exception a base class for all json exceptions
Added root() method to json_deserializer to get a reference to the json value
Removed swap_root() method from json_deserializer
Renamed serialize() class method to to_stream() in json
Custom data serialization supported through template function specialization of serialize (reverses change in 0.17)
Added is_custom() method to json and proxy
get_custom() method renamed to custom_data() in json and proxy
Added clear() method to json and proxy
set_member() method renamed to set()
set_custom() method renamed to set_custom_data()
push_back() method renamed to add() in json and proxy
Added add_custom_data method() in json and proxy
Custom data serialization supported through template class specialization of custom_serialization (replaces template function specialization of serialize)
Change to json_out_stream and json_serializer:
void value(const custom_data& value)
removed.
Free function serialize replaces free function to_stream for serializing custom data.
pretty print tidied up for nested arrays
Made eof() method on json_reader public, to support reading multiple JSON objects from a stream.
Added pretty_print class
Renamed json_stream_writer to json_serializer, implements pure virtual class json_out_stream
Renamed json_stream_listener to json_deserializer implements pure virtual class json_in_stream
Renamed json_parser to json_reader, parse to read.
Changed indenting so object and array members start on new line.
Added support for storing user data in json object, and serializing to JSON.
Replaced simple_string union member with json_string that wraps std::basic_string
name() and value() event handler methods on basic_json_stream_writer take const std::basic_string& rather than const Char* and length.
Implemented operator<< for json::proxy
Added to_stream methods to json::proxy
Added members to json_parser to access and modify the buffer capacity
Added checks when parsing integer values to determine overflow for long long and unsigned long long, and if overflow, parse them as doubles.