/speedyj

Fast and simple JSON serialization 🏎️.

Primary LanguageC++BSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

speedyj

About

Speedyj is a tiny C++ library for JSON serialization.

Building

mkdir build && cd build
cmake .. && cmake --build .

Testing

ctest .

Usage

#include "speedyj/speedyj.hpp"

namespace sj = speedyj;

/* Create a stream. */
sj::Stream s;

/* Serialize on object. */
s << sj::Object
  /* Key/value: */
  << "key" << "value"
  /* Nested array: */
  << "key-to-array" << sj::Array << 1.5 << sj::False << sj::True << sj::Null << sj::End
  /* Nested object: */
  << "nested-object" << sj:Object << "key" << "value" << sj::End
  /* Push std::vector as array: */
  << "vector" << std::vector<int>{{ 1, 2, 3, 4, 5, 6 }}
  /* Push std::map as object: */
  << "map" << std::map<std::string, int>{{"a", 1}, {"b", 2}}
  << sj::End;

/* Get the streams string. */
std::cout << s.str() << "\n";