File: example.cpp

package info (click to toggle)
glaze 7.0.2-3
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 9,036 kB
  • sloc: cpp: 142,035; sh: 98; ansic: 26; makefile: 12
file content (27 lines) | stat: -rw-r--r-- 761 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include "example.hpp"

#include <iostream>

int main()
{
   using namespace example;
   std::vector<person> directory;
   directory.emplace_back(person{"John", "Doe", 33});
   directory.emplace_back(person{"Alice", "Right", 22});

   std::string buffer{};
   std::ignore = glz::write_json(directory, buffer);

   std::cout << buffer << "\n\n";

   std::array<person, 2> another_directory;
   [[maybe_unused]] const auto err = glz::read_json(another_directory, buffer);

   std::string another_buffer{};
   std::ignore = glz::write_json(another_directory, another_buffer);

   std::cout << "Directories are " << (buffer != another_buffer ? "NOT" : "") << "the same!\n";

   const auto success = buffer == another_buffer;
   return static_cast<int>(!success);
}