|Name||Modified||Size||Downloads / Week||Status|
|Totals: 2 Items||150.0 kB||24|
json value, building a
json value in C++ code, and serializing a
json value to a file or string. It also provides an event-based API for reading and writing JSON documents that are too large to fit into available memory, somewhat analogously to SAX processing in the XML world. A brief introduction may be found in jsoncons: a C++ library for json construction.
The library is header-only: it consists solely of header files containing templates and inline functions, and requires no separately-compiled library binaries when linking. It has no dependence on other libraries.
jsoncons uses some features that are new to C++ 11, particularly move semantics, however, it has been written to be compatible with VC++ 10 SP1 (note that SP1 is required for VC++ 10, it fixes compiler bugs with move semantics.) It has been tested with MS Visual C++ 10 SP1, Intel C++ Studio XE 2013, clang 3.3 and GCC 4.8.
To install the jsoncons library, download the zip file, unpack the release, under
src find the directory
jsoncons, and copy it to your
include directory. If you wish to use extensions, copy the
jsoncons_ext directory as well.
wjson_readeretc. Assumes UTF16 encoding if sizeof(wchar_t)=2 and UTF32 encoding if sizeof(wchar_t)=4.
null_typeis added to the
jsonconsnamespace, it replaces the member type json::null_type (json::null_type is typedefed to jsoncons::null_type for backward compatibility.)
escape_all_non_asciiis 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
value_bool- have been renamed to
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
jsonnow has extensibilty, you can access and modify json values with new types, see the tutorial Extensibility
Preparation for allocator support:
jsonand 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
name_value_pair, in particular,
If you have subclassed
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
name_value_pair that has accessors
json_output_handler, allowed for overrides of the
value methods by making them non-virtual and adding virtual methods
Other new features:
Changed implementation of
as<T>, the current implementation should be user extensible
make_multi_array<N> makes a multidimensional array with the number of dimensions specified as a template parameter. Replaces
make_3d_array, which are now deprecated.
Added support for
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:
To clean up the interface and avoid too much duplicated functionality, we've deprecated some json methods (but they still work)
json val(json::an_array) or
json::make_multi_array<1>(...) instead (but
make_array will continue to work)
as<std::vector<int>> etc. instead
as_int as_uint as_char
as<unsigned int>, and
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:
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)
Deprecated features removed
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
output_format to provide a supported way to set the floatfield format flag to
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
is equivalent to
json arr = json::make_array();
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.
resize_array method to
json for resizing json
Fixed issue with
remove_range method (templated code failed to compile if calling this method.)
remove_member method to remove a member from a
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.
output_format methods that support alternative floating point formatting, e.g.
fixed, have been deprecated.
Added a template method as_vector<T> 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
unsigned long long, and
double. For example
json val = json::parse_string(s);
std::vector<int> v = val.as_vector<int>();
json member function
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.
swap member function to
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.
capacity member functions to
csv_serializerhas been added to the
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
fixed_decimal_placesfrom output_format. Use
output_format. For pretty printing with indenting, use the
pretty_printfunction or pass the
output_formatto give more control over floating point notation.
Non functional enhancements
output_formatas a parameter
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
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)
serialize replaces free function
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.
implements pure virtual class
implements pure virtual class
Changed indenting so object and array members start on new line.
Added support for storing user data in
json object, and
serializing to JSON.
simple_string union member with json_string that
name() and value() event handler methods on
const Char* and
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.