libstud-json

[brief]

JSON pull-parser/push-serializer library for C++

A portable, dependency-free, MIT-licensed JSON pull-parser/push-serializer library for C++.

Typical parser usage:

#include <iostream>

#include <libstud/json/parser.hxx>

int main ()
{
  using namespace stud::json;

  parser p (std::cin, "<stdin>");

  for (event e: p)
  {
    switch (e)
    {
    case event::begin_object:
      // ...
    case event::end_object:
      // ...
    case event::name:
      {
        const std::string& n (p.name ());
        // ...
      }
    case event::number:
      {
        int n (p.value<int> ());
        // ...
      }
    }
  }
}

See the libstud/json/parser.hxx header for the parser interface details and the libstud/json/event.hxx header for the complete list of events.

Typical serializer usage:

#include <iostream>

#include <libstud/json/serializer.hxx>

int main ()
{
  using namespace stud::json;

  stream_serializer s (std::cout);

  s.begin_object ();
  s.member ("string", "abc");
  s.member_name ("array");
  s.begin_array ();
  s.value (123);
  s.value (true);
  s.end_array ();
  s.end_object ();
}

See the libstud/json/serializer.hxx header for the serializer interface details.

See the NEWS file for changes and the cppget.org/libstud-json package page for build status.

license MIT
project libstud
url github.com/libstud/libstud-json
topics C++JSONparsingserializationstreaming
1 Version
version 0.1.0
repository pkg:cppget.org/alpha
depends 0