• Stars
    star
    411
  • Rank 101,374 (Top 3 %)
  • Language
    C++
  • License
    Boost Software Li...
  • Created over 4 years ago
  • Updated 23 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A C++11 library for parsing and serializing JSON to and from a DOM container in memory.

Boost.JSON

Branch master develop
Azure Build Status Build Status
Docs Documentation Documentation
Drone Build Status Build Status
Matrix Matrix Matrix
Fuzzing --- fuzz
Appveyor Build status Build status
codecov.io codecov codecov

Boost.JSON

Overview

Boost.JSON is a portable C++ library which provides containers and algorithms that implement JavaScript Object Notation, or simply "JSON", a lightweight data-interchange format. This format is easy for humans to read and write, and easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language (Standard ECMA-262), and is currently standardised in RFC 8259. JSON is a text format that is language-independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.

This library focuses on a common and popular use-case: parsing and serializing to and from a container called value which holds JSON types. Any value which you build can be serialized and then deserialized, guaranteeing that the result will be equal to the original value. Whatever JSON output you produce with this library will be readable by most common JSON implementations in any language.

The value container is designed to be well suited as a vocabulary type appropriate for use in public interfaces and libraries, allowing them to be composed. The library restricts the representable data types to the ranges which are almost universally accepted by most JSON implementations, especially JavaScript. The parser and serializer are both highly performant, meeting or exceeding the benchmark performance of the best comparable libraries. Allocators are very well supported. Code which uses these types will be easy to understand, flexible, and performant.

Boost.JSON offers these features:

  • Fast compilation
  • Require only C++11
  • Fast streaming parser and serializer
  • Constant-time key lookup for objects
  • Options to allow non-standard JSON
  • Easy and safe modern API with allocator support
  • Optional header-only, without linking to a library

Visit https://boost.org/libs/json for complete documentation.

Requirements

  • Requires only C++11
  • Link to a built static or dynamic Boost library, or use header-only (see below)
  • Supports -fno-exceptions, detected automatically

The library relies heavily on these well known C++ types in its interfaces (henceforth termed standard types):

  • string_view
  • memory_resource, polymorphic_allocator
  • error_category, error_code, error_condition, system_error

Header-Only

To use as header-only; that is, to eliminate the requirement to link a program to a static or dynamic Boost.JSON library, simply place the following line in exactly one new or existing source file in your project.

#include <boost/json/src.hpp>

MSVC users must also define the macro BOOST_JSON_NO_LIB to disable auto-linking.

Embedded

Boost.JSON works great on embedded devices. The library uses local stack buffers to increase the performance of some operations. On Intel platforms these buffers are large (4KB), while on non-Intel platforms they are small (256 bytes). To adjust the size of the stack buffers for embedded applications define this macro when building the library or including the function definitions:

#define BOOST_JSON_STACK_BUFFER_SIZE 1024
#include <boost/json/src.hpp>

Endianness

Boost.JSON uses Boost.Endian in order to support both little endian and big endian platforms.

Supported Compilers

Boost.JSON has been tested with the following compilers:

  • clang: 3.5, 3.6, 3.7, 3.8, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
  • gcc: 4.8, 4.9, 5, 6, 7, 8, 9, 10, 11, 12
  • msvc: 14.0, 14.1, 14.2, 14.3

Supported JSON Text

The library expects input text to be encoded using UTF-8, which is a requirement put on all JSON exchanged between systems by the RFC. Similarly, the text generated by the library is valid UTF-8.

The RFC does not allow byte order marks (BOM) to appear in JSON text, so the library considers BOM syntax errors.

The library supports several popular JSON extensions. These have to be explicitly enabled.

Visual Studio Solution

cmake -G "Visual Studio 16 2019" -A Win32 -B bin -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/msvc.cmake
cmake -G "Visual Studio 16 2019" -A x64 -B bin64 -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/msvc.cmake

Quality Assurance

The development infrastructure for the library includes these per-commit analyses:

  • Coverage reports
  • Benchmark performance comparisons
  • Compilation and tests on Drone.io, Azure Pipelines, Appveyor
  • Fuzzing using clang-llvm and machine learning

License

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)

More Repositories

1

boost

Super-project for modularized Boost
HTML
6,236
star
2

beast

HTTP and WebSocket built on Boost.Asio in C++11
C++
4,148
star
3

hana

Your standard library for metaprogramming
C++
1,598
star
4

compute

A C++ GPU Computing Library for OpenCL
C++
1,487
star
5

pfr

std::tuple like methods for user defined types without any macro or boilerplate code
C++
1,221
star
6

asio

Boost.org asio module
C++
1,111
star
7

hof

Higher-order functions for c++
C++
503
star
8

fiber

userland threads
C++
436
star
9

python

Boost.org python module
C++
432
star
10

geometry

Boost.Geometry - Generic Geometry Library | Requires C++14 since Boost 1.75
C++
416
star
11

stacktrace

C++ library for storing and printing backtraces.
C++
374
star
12

spirit

Boost.org spirit module
C++
374
star
13

histogram

Fast multi-dimensional generalized histogram with convenient interface for C++14
C++
308
star
14

math

Boost.org math module
C++
288
star
15

graph

Boost.org graph module
C++
285
star
16

context

Assembly
279
star
17

leaf

Lightweight Error Augmentation Framework
C++
275
star
18

mysql

MySQL C++ client based on Boost.Asio
C++
236
star
19

mp11

C++11 metaprogramming library
C++
225
star
20

build

B2 makes it easy to build C++ projects, everywhere.
C++
224
star
21

safe_numerics

Replacements to standard numeric types which throw exceptions on errors
C++
205
star
22

redis

An async redis client designed for performance and scalability
C++
204
star
23

thread

Boost.org thread module
C++
196
star
24

url

Boost.URL is a library for manipulating Uniform Resource Identifiers (URIs) and Locators (URLs).
C++
177
star
25

multiprecision

Boost.Multiprecision
C++
176
star
26

log

Boost Logging library
C++
173
star
27

gil

Boost.GIL - Generic Image Library | Requires C++14 since Boost 1.80
C++
171
star
28

nowide

Boost.Nowide - Standard library functions with UTF-8 API on Windows
C++
166
star
29

test

The reference C++ unit testing framework (TDD, xUnit, C++03/11/14/17)
C++
165
star
30

cobalt

Coroutines for C++20 & asio
C++
160
star
31

filesystem

Boost.org filesystem module
C++
153
star
32

core

Boost Core Utilities
C++
131
star
33

callable_traits

modern C++ type traits and metafunctions for callable types
C++
129
star
34

interprocess

Boost.org interprocess module
C++
120
star
35

coroutine2

Boost.Coroutine2
C++
120
star
36

serialization

Boost.org serialization module
C++
118
star
37

wiki

Boost Wiki
114
star
38

algorithm

Boost.org algorithm module
C++
109
star
39

lockfree

Boost.Lockfree
C++
109
star
40

smart_ptr

Boost.org smart_ptr module
C++
108
star
41

ublas

Boost.uBlas
C++
105
star
42

yap

A C++14-and-later expression template library
C++
105
star
43

process

Boost Process
C++
101
star
44

container

STL-like containers from Boost
C++
94
star
45

program_options

Boost.org program_options module
C++
92
star
46

preprocessor

Boost.org preprocessor module
C++
89
star
47

qvm

Boost Quaternions, Vectors, Matrices library
C++
80
star
48

coroutine

Boost.Coroutine
C++
79
star
49

regex

Boost.org regex module
C++
78
star
50

uuid

Boost.org uuid module
C++
75
star
51

cmake

CMake support infrastructure Boost submodule
CMake
75
star
52

signals2

Boost.org signals2 module
C++
74
star
53

stl_interfaces

A C++14 and later CRTP template for defining iterators
C++
70
star
54

variant2

A never-valueless, strong guarantee implementation of std::variant
C++
68
star
55

config

Boost.org config module
C++
67
star
56

describe

A C++14 reflection library
C++
66
star
57

date_time

Boost.org date_time module
C++
64
star
58

type_traits

Boost.org type_traits module
C++
60
star
59

poly_collection

Fast containers of polymorphic objects.
C++
60
star
60

static_string

A fixed capacity dynamically sized string
C++
59
star
61

winapi

Windows API declarations without <windows.h>, for internal Boost use.
C++
58
star
62

mpi

Boost.org mpi module
C++
56
star
63

atomic

Boost.Atomic
C++
56
star
64

unordered

Boost.org unordered module
C++
53
star
65

circular_buffer

Boost.org circular_buffer module
C++
51
star
66

sort

Boost.Sort
C++
51
star
67

intrusive

Boost.org intrusive module
C++
50
star
68

optional

Boost.org optional module
C++
50
star
69

polygon

Boost.org polygon module
C++
48
star
70

property_tree

Boost.org property_tree module
C++
48
star
71

fusion

Boost.org fusion module
C++
47
star
72

utility

Boost.org utility module
C++
47
star
73

variant

Boost.org variant module
C++
45
star
74

range

Boost.org range module
C++
43
star
75

metaparse

A library for generating compile time parsers parsing embedded DSL code as part of the C++ compilation process
C++
43
star
76

endian

Boost Endian library
C++
43
star
77

mpl

Boost.org mpl module
C++
43
star
78

predef

Boost.Predef (a Boost C++ Library)
C
43
star
79

iostreams

Boost.org iostreams module
C++
41
star
80

multi_index

Boost.org multi_index module
C++
41
star
81

contract

Contract programming for C++
C++
40
star
82

odeint

Boost.odeint
C++
39
star
83

outcome

Provides very lightweight outcome<T> and result<T> (Boost edition)
C++
38
star
84

pool

Boost.org pool module
C++
37
star
85

dynamic_bitset

Boost.org dynamic_bitset module
C++
36
star
86

random

Boost.org random module
C++
34
star
87

assert

Boost.Assert
C++
32
star
88

any

Boost.org any module
C++
32
star
89

system

Boost.org system module
C++
32
star
90

msm

Boost.org msm module
C++
29
star
91

container_hash

Generic hash function for STL style unordered containers
C++
29
star
92

locale

Boost.Locale
C++
29
star
93

units

Boost.org units module
C++
28
star
94

bind

Boost.org bind module
C++
27
star
95

phoenix

Boost.org phoenix module
C++
27
star
96

multi_array

Boost.org multi_array module
C++
25
star
97

format

Boost.org format module
C++
25
star
98

lexical_cast

General literal text conversions, such as an int represented as a string, or vice versa
C++
25
star
99

website

The boost website.
HTML
23
star
100

statechart

Boost.org statechart module
C++
23
star