s */ .boostlook:not(:has(.doc)) .titlepage hr { display: none; } /* Table of Contents */ .boostlook:not(:has(.doc)) div.toc { color: var(--text-main-text-body-secondary, #494d50); font-family: var(--font-family-body, "Noto Sans"); font-size: var(--typography-font-size-xs, 0.875rem); font-style: normal; line-height: var(--typography-line-height-md, 1.25rem); margin: 0; margin-bottom: var(--padding-padding-md, 1.125rem); padding: 0; border: none; } .boostlook:not(:has(.doc)) div.toc > p { display: flex; padding: var(--spacing-size-3xs, 0.25rem); color: var(--text-main-text-primary, #18191b); font-size: var(--typography-font-size-2xs, 0.75rem); font-variation-settings: "wght" 600, "wdth" 80; line-height: var(--typography-line-height-sm, 1rem); /* 133.333% */ letter-spacing: var(--spacing-size-size-0, 0rem); } .boostlook:not(:has(.doc)) div.toc > p > * { font: inherit; color: inherit; } .boostlook:not(:has(.doc)) div.toc .toc dt { color: var(--text-main-text-body-secondary, #494d50); font-size: var(--typography-font-size-xs, 0.875rem); font-style: normal; line-height: var(--typography-line-height-md, 1.25rem); } .boostlook:not(:has(.doc)) div.toc dd dd { padding-left: var(--leftbar-paddings-leftbar-padding-sm); } /* Section Layout */ .boostlook#boost-legacy-docs-wrapper:not(:has(.doc)):not(:has(> .boostlook)) > *, .boostlook#antora-template-wrapper:not(:has(.doc)):not(:has(> .boostlook)) > *, div.source-docs-antora.boostlook:not(:has(.doc)):not(:has(> .boostlook)) > * { /* max-width: var(--main-content-width); margin-left: inherit; margin-right: inherit; */ margin: 0 auto; } /* hide footer spirit nav since it wasn't visible before */ .boostlook:not(:has(.doc)) div:nth-of-type(4).spirit-nav, .boostlook#boost-legacy-docs-wrapper div.spirit-nav:last-child, .boostlook#antora-template-wrapper div.spirit-nav:last-child, div.source-docs-antora.boostlook:not(:has(.doc)):not(:has(> .boostlook)) div.spirit-nav:last-child { display: none !important; } /* hidden elems */ .boostlook:not(:has(.doc)) > hr, .boostlook:not(:has(.doc)) .table-break { display: none; } /* Content Blocks */ .boostlook:not(:has(.doc)) .inlinemediaobject:has(> img):first-child:last-child { margin: var(--padding-padding-xs, 0.75rem) 0; } .boostlook:not(:has(.doc)) a:is(h1 a, h2 a, h3 a, h4 a, h5 a) code { background: transparent !important; border: none; font-size: inherit; color: inherit; padding: 0; display: initial; transition: none; } /* Special Blocks */ /* hide legacy icon */ .boostlook:not(:has(.doc)) div:not(.admonitionblock).note > table tr:first-child td, .boostlook:not(:has(.doc)) div:not(.admonitionblock).tip > table tr:first-child td, .boostlook:not(:has(.doc)) div:not(.admonitionblock).important > table tr:first-child td, .boostlook:not(:has(.doc)) div:not(.admonitionblock).caution > table tr:first-child td, .boostlook:not(:has(.doc)) div:not(.admonitionblock).warning > table tr:first-child td, .boostlook:not(:has(.doc)) div:not(.admonitionblock).blurb > table tr:first-child td, .boostlook:not(:has(.doc)) p.blurb > table tr:first-child td { display: none; } /* Special Blocks Margins */ .boostlook:not(:has(.doc)) div.note, .boostlook:not(:has(.doc)) div.tip, .boostlook:not(:has(.doc)) div.important, .boostlook:not(:has(.doc)) div.caution, .boostlook:not(:has(.doc)) div.warning, .boostlook:not(:has(.doc)) div.blurb, .boostlook:not(:has(.doc)) p.blurb { margin-top: var(--padding-padding-xs, 0.75rem); margin-bottom: var(--padding-padding-2xs); } .boostlook:not(:has(.doc)) .titlepage + div.note, .boostlook:not(:has(.doc)) .titlepage + div.tip, .boostlook:not(:has(.doc)) .titlepage + div.important, .boostlook:not(:has(.doc)) .titlepage + div.caution, .boostlook:not(:has(.doc)) .titlepage + div.warning, .boostlook:not(:has(.doc)) .titlepage + div.blurb, .boostlook:not(:has(.doc)) .titlepage + p.blurb { margin-top: var(--padding-padding-2xs); } /* Tables */ /* Make div with Table display block */ .boostlook:has(:not(.doc)) div.table { display: block; } /* Enable Horizontal Scroll */ .boostlook:has(:not(.doc)) div.table .table-contents, .boostlook:has(:not(.doc)) .informaltable:has(> .table) { overflow: auto; } /* References Table */ /* This is specific selector for refences tables which containes many tables and only tables as direct children */ .boostlook:has(:not(.doc)) .informaltable:has(> table:nth-of-type(2)):not(:has(> *:not(table))) { display: flex; flex-direction: column; gap: var(--padding-padding-md, 1.125rem); /* border: 2px solid red; */ } /* Disable margins for all Headings inside table */ .boostlook:has(:not(.doc)) .informaltable:has(> .table) :is(h1, h2, h3, h4, h5, h6) { margin: 0; } /* Table has inner table th */ .boostlook:has(:not(.doc)) .informaltable:has(> table:nth-of-type(2)):not(:has(> *:not(table))) .table:has(.simplelist) th { border: none; padding: 0 0 var(--padding-padding-xs, 0.75rem) 0; background: none; color: var(--text-main-text-primary, #18191b); font-size: var(--typography-font-size-md, 1.125rem); font-style: normal; font-variation-settings: "wght" 500, "wdth" 80; line-height: var(--typography-line-height-xl, 1.75rem); /* 155.556% */ letter-spacing: var(--spacing-size-size-0, 0rem); } /* Disable global cell paddings */ .boostlook:has(:not(.doc)) .informaltable:has(> table:nth-of-type(2)):not(:has(> *:not(table))) .table:has(.simplelist) > tbody > tr > td { padding: 0; } /* Add border radius to tbody first row */ .boostlook:has(:not(.doc)) .informaltable:has(> table:nth-of-type(2)):not(:has(> *:not(table))) .table:has(.simplelist) tr:last-child td:first-child { border-top-left-radius: var(--spacing-size-2xs, 0.5rem); overflow: hidden; } /* Add border radius to tbody first row */ .boostlook:has(:not(.doc)) .informaltable:has(> table:nth-of-type(2)):not(:has(> *:not(table))) .table:has(.simplelist) tr:last-child td:last-child { border-top-right-radius: var(--spacing-size-2xs, 0.5rem); overflow: hidden; } /* Select Inner Headings and make it look as table head */ .boostlook:has(:not(.doc)) .informaltable:has(> table:nth-of-type(2)):not(:has(> *:not(table))) .table:has(.simplelist) tbody :is(h1, h2, h3, h4, h5, h6) { padding: var(--padding-padding-3xs, 0.25rem) var(--padding-padding-2xs, 0.5rem); gap: var(--spacing-size-xs, 0.75rem); background: var(--surface-background-main-surface-primary, #f5f6f8); color: var(--text-main-text-body-tetriary, #62676b); font-size: var(--typography-font-size-xs, 0.875rem); font-style: normal; font-variation-settings: "wght" 500, "wdth" 80; line-height: var(--typography-line-height-lg, 1.5rem); /* 171.429% */ letter-spacing: var(--spacing-size-size-0, 0rem); } /* Inner table styles */ .boostlook:has(:not(.doc)) .informaltable:has(> table:nth-of-type(2)):not(:has(> *:not(table))) table.simplelist { width: 100%; } .boostlook:has(:not(.doc)) .informaltable:has(> table:nth-of-type(2)):not(:has(> *:not(table))) table.simplelist td { border: none; padding: var(--padding-padding-3xs, 0.25rem) var(--padding-padding-2xs, 0.5rem); } /* Footnotes */ .boostlook:has(:not(.doc)) .footnotes { margin-top: var(--padding-padding-lg); border-top: 1px solid var(--border-border-primary); } .boostlook:has(:not(.doc)) .footnotes hr { display: none; } /* Copyright Footer */ /* If Footer has no content than use it as bottom spacer */ .boostlook .copyright-footer:empty { padding-top: var(--main-margin); } /* If Footer has content */ .boostlook .copyright-footer:not(:empty) { padding: var(--padding-padding-lg) 0; } /* Footer Content */ .boostlook:not(:has(.doc)) .copyright-footer { color: var(--text-main-text-body-quaternary, #949a9e); font-size: var(--typography-font-size-xs); font-variation-settings: "wght" 500, "wdth" 80; line-height: var(--typography-line-height-sm, 1rem); letter-spacing: var(--spacing-size-size-0, 0rem); text-align: left; } /* Footer Content */ .boostlook:not(:has(.doc)) .copyright-footer p { text-align: inherit; font-size: var(--typography-font-size-2xs); color: var(--text-main-text-body-primary, #2a2c30); } /* Outcome 2.2 Weird Template fix */ .boostlook:not(:has(.doc))#boost-legacy-docs-wrapper > #content hr, .boostlook:not(:has(.doc))#antora-template-wrapper > #content hr, div.source-docs-antora.boostlook:not(:has(.doc)):not(:has(> .boostlook)) > #content hr { display: none; } /* Outcome 2.2 Weird Template fix */ .boostlook:not(:has(.doc))#boost-legacy-docs-wrapper > #content div.code-snippet, .boostlook:not(:has(.doc))#antora-template-wrapper > #content div.code-snippet, div.source-docs-antora.boostlook:not(:has(.doc)):not(:has(> .boostlook)) > #content div.code-snippet { position: relative; } /* Outcome 2.2 Weird Template fix */ .boostlook:not(:has(.doc))#boost-legacy-docs-wrapper > #content div.highlight:has(> pre), .boostlook:not(:has(.doc))#antora-template-wrapper > #content div.highlight:has(> pre), div.source-docs-antora.boostlook:not(:has(.doc)):not(:has(> .boostlook)) > #content div.highlight:has(> pre) { margin: 0; border: none; padding: 0; } /* Outcome 2.2 Weird Template fix */ .boostlook:not(:has(.doc))#boost-legacy-docs-wrapper > #content div.highlight:has(> pre) pre, .boostlook:not(:has(.doc))#antora-template-wrapper > #content div.highlight:has(> pre) pre, div.source-docs-antora.boostlook:not(:has(.doc)):not(:has(> .boostlook)) > #content div.highlight:has(> pre) pre { padding: var(--spacing-size-xs, 0.75rem) var(--spacing-size-sm, 1rem); margin-top: var(--padding-padding-3xs, 0.25rem); } /* Outcome 2.2 Weird Template fix */ .boostlook:not(:has(.doc))#boost-legacy-docs-wrapper > #content > pre:not([class]), .boostlook:not(:has(.doc))#antora-template-wrapper > #content > pre:not([class]), div.source-docs-antora.boostlook:not(:has(.doc)):not(:has(> .boostlook)) > #content > pre:not([class]) { margin-left: 0; margin-right: 0; } /* Outcome 2.2 Weird Template fix */ .boostlook:not(:has(.doc))#boost-legacy-docs-wrapper > #content div.code-snippet:has(pre):not(:last-child) pre:not([class]), .boostlook:not(:has(.doc))#antora-template-wrapper > #content div.code-snippet:has(pre):not(:last-child) pre:not([class]), div.source-docs-antora.boostlook:not(:has(.doc)):not(:has(> .boostlook)) > #content div.code-snippet:has(pre):not(:last-child) pre:not([class]), .boostlook:not(:has(.doc))#boost-legacy-docs-wrapper > #content > pre:not([class]):not(:last-child), .boostlook:not(:has(.doc))#antora-template-wrapper > #content > pre:not([class]):not(:last-child), div.source-docs-antora.boostlook:not(:has(.doc)):not(:has(> .boostlook)) > #content > pre:not([class]):not(:last-child), .boostlook:not(:has(.doc))#boost-legacy-docs-wrapper > #content div.code-snippet:not(:last-child) pre, .boostlook:not(:has(.doc))#antora-template-wrapper > #content div.code-snippet:not(:last-child) pre, div.source-docs-antora.boostlook:not(:has(.doc)):not(:has(> .boostlook)) > #content div.code-snippet:not(:last-child) pre { margin-bottom: var(--padding-padding-xs, 0.75rem); } /* Outcome 2.2 Weird Template fix */ .boostlook:not(:has(.doc))#boost-legacy-docs-wrapper > #content + p:has(> small), .boostlook:not(:has(.doc))#antora-template-wrapper > #content + p:has(> small), div.source-docs-antora.boostlook:not(:has(.doc)):not(:has(> .boostlook)) > #content + p:has(> small) { padding: var(--padding-padding-lg) 0 !important; } /* Outcome 2.2 Weird Template fix */ .boostlook:not(:has(.doc))#boost-legacy-docs-wrapper > #content .footnotes, .boostlook:not(:has(.doc))#antora-template-wrapper > #content .footnotes, div.source-docs-antora.boostlook:not(:has(.doc)):not(:has(> .boostlook)) > #content .footnotes { padding-top: var(--padding-padding-xs, 0.75rem); } @media screen and (min-width: 768px) { body.article:has(.boostlook#boost-legacy-docs-wrapper), body.article:has(.boostlook#antora-template-wrapper), body.article:has(div.source-docs-antora.boostlook) { /* !important ovverides website own styles !important * Adjust this to "padding: 0 1rem 0 1rem" * when website container width will be used as in new look design */ padding: 0 !important; } #boost-legacy-docs-wrapper .boostlook #toc.toc2, #antora-template-wrapper .boostlook #toc.toc2, div.source-docs-antora.boostlook:has(> .boostlook) .boostlook #toc.toc2 { /* Adjust this to "max(1rem, 50% - 45rem)" * when website container width will be used as in new look design */ left: max(0rem, 50% - 45rem); } } /* TOC Common End */ /*----------------- Quickbook Documentation Styles end -----------------*/ /*----------------- Library README Styles start -----------------*/ .boostlook#libraryReadMe { margin-left: 0; } .boostlook#libraryReadMe > * { max-width: unset; margin-left: inherit; margin-right: inherit; } .boostlook#libraryReadMe > h1:first-child { margin-top: 0; } .boostlook#libraryReadMe div.highlight:has(> pre) { background: transparent !important; } .boostlook#libraryReadMe p:has(> a img ) { display:flex; flex-wrap:wrap; justify-content: flex-start; align-items: center; } .boostlook#libraryReadMe p a:has(> img ) { margin-left:.5rem; } .boostlook#libraryReadMe > pre:not(:is(dd pre, td pre)) { padding: var(--spacing-size-xs, 0.75rem) var(--spacing-size-sm, 1rem); border: 1px solid var(--border-border-secondary, #d5d7d9); } /*----------------- Library README Styles end -----------------*/ /*----------------- AsciiDoctor-Specific Responsive TOC Layout start -----------------*/ /* Prevent header/content/footer padding from jumping at 990px breakpoint */ @media (min-width: 990px) { :root { --main-max-width-leftbar: 18.25rem; --main-margin: var(--spacing-size-xl); } } /* === Tablet/Desktop: TOC Sidebar Layout (768px+) === */ @media screen and (min-width: 768px) { .boostlook #toc.toc2 { position: fixed !important; left: 0 !important; width: var(--main-max-width-leftbar) !important; top: 0 !important; height: 100vh !important; } .boostlook #toggle-toc { position: fixed !important; left: 1rem !important; top: 2rem !important; } .toc2 .boostlook:has(> #content .doc) { margin-left: 0; } html.toc-visible .boostlook { margin-left: 0 !important; } } /* === Large Screens: Maintain Offset Layout (1280px+) === */ @media screen and (min-width: 768px) { .article.toc2.toc-left { max-width: none !important; } html:not(.toc-hidden, .toc-visible) .article.toc2.toc-left, .toc-visible.toc-pinned .article.toc2.toc-left { margin-left: var(--main-max-width-leftbar) !important; } } /* === Wide Screens: Expanded Content Width (1536px+) === */ @media screen and (min-width: 1536px) { :root { --main-content-width: 1100px; --main-content-left-spacing: 2rem; } } /* === Ultra-Wide Screens: Maximum content width (1920px+) === */ @media screen and (min-width: 1920px) { :root { --main-content-width: 1300px; --main-content-left-spacing: 4rem; } .boostlook #content, .boostlook #header > h1, .boostlook #header .author { margin-left: var(--main-content-left-spacing); } } /*----------------- AsciiDoctor-Specific Responsive TOC Layout end -----------------*/
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
Requirements Requires only C++11
Link to a built static or dynamic Boost library (build instructions can be found here ), or use header-only (see below)
Additional link to Boost.Container may be required (as described in its documentation )
Supports -fno-exceptions
, detected automatically (but read the relevant section on this page).
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
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. Note, that if you also want to avoid linking to Boost.Container, which is a dependency of Boost.JSON, you have to define BOOST_CONTAINER_NO_LIB
. In order to disable auto-linking to Boost libraries completely you can define BOOST_ALL_NO_LIB
instead.
Disabling Exceptions In order to support building with exceptions disabled this library uses another Boost library, Boost.ThrowException . This allows to automatically discover whether exception support is available. On the other hand, as explained in Boost.ThrowException’s documentation, if exceptions are disabled, the users need to provide their own implementation for boost::throw_exception
, in order to link their binaries successfully. Here’s a very simple example of such implementation:
void throw_exception ( const std :: exception & , const boost :: source_location & ) { std :: printf ( "Exceptions are not supported!" ); std :: abort (); }
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: 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.
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
Security Review (Bishop Fox) Credits This library wouldn’t be where it is today without the help of Peter Dimov for design advice and optimization assistance.