Skip to content

Releases: stephenberry/glaze

1.3.1

10 Jul 15:34
Compare
Choose a tag to compare
  • 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

02 Jul 13:55
Compare
Choose a tag to compare

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 and writable_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 and glz::invoke_update, which allow invoking functions when reading JSON input
  • Added GLZ_QUOTED_X helper macro (thanks @pwqbot)

1.2.6

14 Jun 15:43
Compare
Choose a tag to compare
  • 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 the glz::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

06 Jun 15:50
Compare
Choose a tag to compare
  • 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 using empty where possible for better performance with containers like std::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

31 May 04:46
Compare
Choose a tag to compare
  • 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.

1.2.3

06 May 11:34
Compare
Choose a tag to compare

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 JSON null
  • 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

25 Apr 22:52
Compare
Choose a tag to compare
  • 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

19 Apr 20:55
Compare
Choose a tag to compare
  • Added .at() to json_t (from @RozeFound)
  • Fixed dead constexpr branch of csv code

1.2.0

13 Apr 19:54
Compare
Choose a tag to compare

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

30 Mar 19:54
Compare
Choose a tag to compare

See version 1.1.1 notes for more recent updates.

  • CSV api changes to be more readable (switching between row-wise and column-wise)