Releases: stephenberry/glaze
1.3.1
- Added
glz::merge
, which allows users to merge JSON object types (suggested by @GJanos)
glz::obj o{"pi", 3.141};
std::map<std::string_view, int> map = {{"a", 1}, {"b", 2}, {"c", 3}};
auto merged = glz::merge{o, map};
std::string s{};
glz::write_json(merged, s); // will write out a single, merged object
// s is now: {"pi":3.141,"a":0,"b":2,"c":3}
- Fixed null
char*
issues and added better concepts for char array handling (Thanks @maor-da) - Fixed std::max/std::min macro issues with MSVC (Thanks @alfedotov)
1.3.0
BREAKING v1.3.0 CHANGE: std::pair is now handled as a JSON object ({"first":second}}. If you require a JSON array of two items, use std::array or std::tuple.
Removed MSVC 2019 support (the compiler has too many limitations for ranges and compile time logic)
- Added numeric enum support (default behavior)
- std::string reading with CSV format
- Added separate concepts for
readable_map_t
andwritable_map_t
(thanks @justend29) - Views and ranges of
std::pair
can now be serialized as objects: (thanks @justend29)
auto num_view =
std::views::iota(-2, 3) | std::views::transform([](const auto i) { return std::pair(i, i * i); });
expect(glz::write_json(num_view) == glz::sv{R"({"-2":4,"-1":1,"0":0,"1":1,"2":4})"});
- Added
glz::invoke
andglz::invoke_update
, which allow invoking functions when reading JSON input - Added
GLZ_QUOTED_X
helper macro (thanks @pwqbot)
1.2.6
- Added the ability to write out
static constexpr
values. These and other const qualified members are skipped when reading in. - Added
glaze_exceptions.hpp
, which adds throwing functions in theglz::ex
namespace for cleaner coding when exceptions are used. - Indent prettify fix for empty maps (@justend29)
- Added missing header for gcc13 (@justend29)
1.2.5
- Building again with MinGW
- JSON pointer array access has been fixed: e.g.
auto x0 = glz::get_as_json<int, "/obj/x/0">(s);
- Indent fix for prettify when
[]
is empty, and usingempty
where possible for better performance with containers likestd::list
(thanks @justend29) - Read and write file functions now take in the buffer, which allows for buffer reuse and better performance:
auto ec = glz::read_file_json(obj, "./obj.txt", std::string{});
The non-buffer versions are now deprecated with messages to add the buffer as the last argument. These have been deprecated because it is best for users to be aware of where allocations are happening.
1.2.4
- New logging structures (currently only writing is supported):
Sometimes you just want to write out JSON structures on the fly as efficiently as possible. Glaze provides tuple-like structures that allow you to stack allocate structures to write out JSON with high speed. These structures are named glz::obj
for objects and glz::arr
for arrays.
Below is an example of building an object, which also contains an array, and writing it out.
auto obj = glz::obj{"pi", 3.14, "happy", true, "name", "Stephen", "arr", glz::arr{"Hello", "World", 2}};
std::string s{};
glz::write_json(obj, s);
expect(s == R"({"pi":3.14,"happy":true,"name":"Stephen","arr":["Hello","World",2]})");
This approach is significantly faster than
glz::json_t
for generic JSON. But, may not be suitable for all contexts.
- Fixed prettify of tagged variants (@justend29)
- Support for parsing empty sets (@justend29)
- Added support for modern C++ modules (@katazina0)
1.2.3
Improvements and new features:
- Support for raw character buffers as JSON strings (e.g.
char buffer[18]
) std::monostate
now roundtrips and is treated as a JSONnull
- A
glz::number<&T::my_string>()
wrapper has been added that allows JSON numbers to be kept in string form - Removed old thread affinity code and Windows.h header include
- CMake cleanup (@justend29)
- Other minor bug fixes and cleanup
1.2.2
- Better hash algorithm for small, compile time maps (less collisions means faster compilation)
Quoted Numbers
You can parse quoted JSON numbers directly to types like double
, int
, etc. by utilizing the glz::quoted
wrapper.
struct A {
double x;
std::vector<uint32_t> y;
};
template <>
struct glz::meta<A> {
static constexpr auto value = object("x", glz::quoted<&A::x>(), "y", glz::quoted<&A::y>());
};
{
"x": "3.14",
"y": ["1", "2", "3"]
}
The quoted JSON numbers will be parsed directly into the double
and std::vector<uint32_t>
. The glz::quoted
function works for nested objects and arrays as well.
1.2.1
- Added
.at()
tojson_t
(from @RozeFound) - Fixed dead constexpr branch of csv code
1.2.0
Breaking changes to binary (Crusher) specification and implementation in Glaze. We looked into implementing CBOR, but the performance would have been much worse. The specification now directly maps to JSON. It fulfills the same role as CBOR, but with much higher performance and in some cases better compression (smaller sizes).
Other changes:
- Faster JSON reading
- Improved compile time maps
- Simplified internal code along with minor improvements and cleaning
1.1.2
See version 1.1.1 notes for more recent updates.
- CSV api changes to be more readable (switching between row-wise and column-wise)