json.hpp(3) Library Functions Manual json.hpp(3)

# [NAME](#NAME)

json.hpp - JSON input and output archives.

# [SYNOPSIS](#SYNOPSIS)

#include 'cereal/cereal.hpp'  
#include 'cereal/details/util.hpp'  
#include 'cereal/external/rapidjson/prettywriter.h'  
#include 'cereal/external/rapidjson/ostreamwrapper.h'  
#include 'cereal/external/rapidjson/istreamwrapper.h'  
#include 'cereal/external/rapidjson/document.h'  
#include 'cereal/external/base64.hpp'  
#include &lt;limits&gt;  
#include &lt;sstream&gt;  
#include &lt;stack&gt;  
#include &lt;vector&gt;  
#include &lt;string&gt;

## [Classes](#Classes)

struct **cereal::RapidJSONException**  
An exception thrown when rapidjson fails an internal assertion. class **cereal::JSONOutputArchive**  
An output archive designed to save data to JSON. class **cereal::JSONOutputArchive::Options**  
A class containing various advanced options for the JSON archive. class **cereal::JSONInputArchive**  
An input archive designed to load data from JSON.

## [Macros](#Macros)

#define **CEREAL\_RAPIDJSON\_ASSERT\_THROWS**  
#define **CEREAL\_RAPIDJSON\_ASSERT**(x)  
#define **CEREAL\_RAPIDJSON\_WRITE\_DEFAULT\_FLAGS** kWriteNanAndInfFlag  
#define **CEREAL\_RAPIDJSON\_PARSE\_DEFAULT\_FLAGS** kParseFullPrecisionFlag | kParseNanAndInfFlag

## [Functions](#Functions)

template&lt;class T&gt; void **cereal::prologue** (**JSONOutputArchive** &, **NameValuePair**&lt; T &gt; const &)  
Prologue for NVPs for JSON archives. template&lt;class T&gt; void **cereal::prologue** (**JSONInputArchive** &, **NameValuePair**&lt; T &gt; const &)  
Prologue for NVPs for JSON archives. template&lt;class T&gt; void **cereal::epilogue** (**JSONOutputArchive** &, **NameValuePair**&lt; T &gt; const &)  
Epilogue for NVPs for JSON archives. template&lt;class T&gt; void **cereal::epilogue** (**JSONInputArchive** &, **NameValuePair**&lt; T &gt; const &)  
Epilogue for NVPs for JSON archives. template&lt;class T&gt; void **cereal::prologue** (**JSONOutputArchive** &, **DeferredData**&lt; T &gt; const &)  
Prologue for deferred data for JSON archives. template&lt;class T&gt; void **cereal::prologue** (**JSONInputArchive** &, **DeferredData**&lt; T &gt; const &)  
Prologue for deferred data for JSON archives. template&lt;class T&gt; void **cereal::epilogue** (**JSONOutputArchive** &, **DeferredData**&lt; T &gt; const &)  
Epilogue for deferred for JSON archives. template&lt;class T&gt; void **cereal::epilogue** (**JSONInputArchive** &, **DeferredData**&lt; T &gt; const &)  
Epilogue for deferred for JSON archives. template&lt;class T&gt; void **cereal::prologue** (**JSONOutputArchive** &ar, **SizeTag**&lt; T &gt; const &)  
Prologue for SizeTags for JSON archives. template&lt;class T&gt; void **cereal::prologue** (**JSONInputArchive** &, **SizeTag**&lt; T &gt; const &)  
Prologue for SizeTags for JSON archives. template&lt;class T&gt; void **cereal::epilogue** (**JSONOutputArchive** &, **SizeTag**&lt; T &gt; const &)  
Epilogue for SizeTags for JSON archives. template&lt;class T&gt; void **cereal::epilogue** (**JSONInputArchive** &, **SizeTag**&lt; T &gt; const &)  
Epilogue for SizeTags for JSON archives. template&lt;class T, traits::EnableIf&lt;!std::is\_arithmetic&lt; T &gt;::value, !**traits::has\_minimal\_base\_class\_serialization**&lt; T, **traits::has\_minimal\_output\_serialization**, **JSONOutputArchive** &gt;::value, !**traits::has\_minimal\_output\_serialization**&lt; T, **JSONOutputArchive** &gt;::value &gt; = traits::sfinae&gt; void **cereal::prologue** (**JSONOutputArchive** &ar, T const &)  
Prologue for all other types for JSON archives (except minimal types). template&lt;class T, traits::EnableIf&lt;!std::is\_arithmetic&lt; T &gt;::value, !**traits::has\_minimal\_base\_class\_serialization**&lt; T, **traits::has\_minimal\_input\_serialization**, **JSONInputArchive** &gt;::value, !**traits::has\_minimal\_input\_serialization**&lt; T, **JSONInputArchive** &gt;::value &gt; = traits::sfinae&gt; void **cereal::prologue** (**JSONInputArchive** &ar, T const &)  
Prologue for all other types for JSON archives. template&lt;class T, traits::EnableIf&lt;!std::is\_arithmetic&lt; T &gt;::value, !**traits::has\_minimal\_base\_class\_serialization**&lt; T, **traits::has\_minimal\_output\_serialization**, **JSONOutputArchive** &gt;::value, !**traits::has\_minimal\_output\_serialization**&lt; T, **JSONOutputArchive** &gt;::value &gt; = traits::sfinae&gt; void **cereal::epilogue** (**JSONOutputArchive** &ar, T const &)  
Epilogue for all other types other for JSON archives (except minimal types). template&lt;class T, traits::EnableIf&lt;!std::is\_arithmetic&lt; T &gt;::value, !**traits::has\_minimal\_base\_class\_serialization**&lt; T, **traits::has\_minimal\_input\_serialization**, **JSONInputArchive** &gt;::value, !**traits::has\_minimal\_input\_serialization**&lt; T, **JSONInputArchive** &gt;::value &gt; = traits::sfinae&gt; void **cereal::epilogue** (**JSONInputArchive** &ar, T const &)  
Epilogue for all other types other for JSON archives. void **cereal::prologue** (**JSONOutputArchive** &ar, std::nullptr\_t const &)  
Prologue for arithmetic types for JSON archives. void **cereal::prologue** (**JSONInputArchive** &, std::nullptr\_t const &)  
Prologue for arithmetic types for JSON archives. void **cereal::epilogue** (**JSONOutputArchive** &, std::nullptr\_t const &)  
Epilogue for arithmetic types for JSON archives. void **cereal::epilogue** (**JSONInputArchive** &, std::nullptr\_t const &)  
Epilogue for arithmetic types for JSON archives. template&lt;class T, traits::EnableIf&lt; std::is\_arithmetic&lt; T &gt;::value &gt; = traits::sfinae&gt; void **cereal::prologue** (**JSONOutputArchive** &ar, T const &)  
Prologue for arithmetic types for JSON archives. template&lt;class T, traits::EnableIf&lt; std::is\_arithmetic&lt; T &gt;::value &gt; = traits::sfinae&gt; void **cereal::prologue** (**JSONInputArchive** &, T const &)  
Prologue for arithmetic types for JSON archives. template&lt;class T, traits::EnableIf&lt; std::is\_arithmetic&lt; T &gt;::value &gt; = traits::sfinae&gt; void **cereal::epilogue** (**JSONOutputArchive** &, T const &)  
Epilogue for arithmetic types for JSON archives. template&lt;class T, traits::EnableIf&lt; std::is\_arithmetic&lt; T &gt;::value &gt; = traits::sfinae&gt; void **cereal::epilogue** (**JSONInputArchive** &, T const &)  
Epilogue for arithmetic types for JSON archives. template&lt;class CharT, class Traits, class Alloc&gt; void **cereal::prologue** (**JSONOutputArchive** &ar, std::basic\_string&lt; CharT, Traits, Alloc &gt; const &)  
Prologue for strings for JSON archives. template&lt;class CharT, class Traits, class Alloc&gt; void **cereal::prologue** (**JSONInputArchive** &, std::basic\_string&lt; CharT, Traits, Alloc &gt; const &)  
Prologue for strings for JSON archives. template&lt;class CharT, class Traits, class Alloc&gt; void **cereal::epilogue** (**JSONOutputArchive** &, std::basic\_string&lt; CharT, Traits, Alloc &gt; const &)  
Epilogue for strings for JSON archives. template&lt;class CharT, class Traits, class Alloc&gt; void **cereal::epilogue** (**JSONInputArchive** &, std::basic\_string&lt; CharT, Traits, Alloc &gt; const &)  
Epilogue for strings for JSON archives. template&lt;class T&gt; void **cereal::CEREAL\_SAVE\_FUNCTION\_NAME** (**JSONOutputArchive** &ar, **NameValuePair**&lt; T &gt; const &t)  
Serializing NVP types to JSON. template&lt;class T&gt; void **cereal::CEREAL\_LOAD\_FUNCTION\_NAME** (**JSONInputArchive** &ar, **NameValuePair**&lt; T &gt; &t)  
void **cereal::CEREAL\_SAVE\_FUNCTION\_NAME** (**JSONOutputArchive** &ar, std::nullptr\_t const &t)  
Saving for nullptr to JSON. void **cereal::CEREAL\_LOAD\_FUNCTION\_NAME** (**JSONInputArchive** &ar, std::nullptr\_t &t)  
Loading arithmetic from JSON. template&lt;class T, traits::EnableIf&lt; std::is\_arithmetic&lt; T &gt;::value &gt; = traits::sfinae&gt; void **cereal::CEREAL\_SAVE\_FUNCTION\_NAME** (**JSONOutputArchive** &ar, T const &t)  
Saving for arithmetic to JSON. template&lt;class T, traits::EnableIf&lt; std::is\_arithmetic&lt; T &gt;::value &gt; = traits::sfinae&gt; void **cereal::CEREAL\_LOAD\_FUNCTION\_NAME** (**JSONInputArchive** &ar, T &t)  
Loading arithmetic from JSON. template&lt;class CharT, class Traits, class Alloc&gt; void **cereal::CEREAL\_SAVE\_FUNCTION\_NAME** (**JSONOutputArchive** &ar, std::basic\_string&lt; CharT, Traits, Alloc &gt; const &str)  
saving string to JSON template&lt;class CharT, class Traits, class Alloc&gt; void **cereal::CEREAL\_LOAD\_FUNCTION\_NAME** (**JSONInputArchive** &ar, std::basic\_string&lt; CharT, Traits, Alloc &gt; &str)  
loading string from JSON template&lt;class T&gt; void **cereal::CEREAL\_SAVE\_FUNCTION\_NAME** (**JSONOutputArchive** &, **SizeTag**&lt; T &gt; const &)  
Saving SizeTags to JSON. template&lt;class T&gt; void **cereal::CEREAL\_LOAD\_FUNCTION\_NAME** (**JSONInputArchive** &ar, **SizeTag**&lt; T &gt; &st)  
Loading SizeTags from JSON.

# [Detailed Description](#Detailed_Description)

JSON input and output archives.

# [Macro Definition Documentation](#Macro_Definition_Documentation)

## [#define CEREAL\_RAPIDJSON\_ASSERT( x)](#_define_CEREAL_RAPIDJSON_ASSERT%28_x%29)

**Value:**

```
if(!(x)){ \
throw ::cereal::RapidJSONException("rapidjson internal assertion failure: " #x); }
```

```

```

# [Function Documentation](#Function_Documentation)

## template&lt;class T&gt; void cereal::epilogue (**JSONInputArchive** & , **DeferredData**&lt; T &gt; const & ) \[inline]

Epilogue for deferred for JSON archives. Do nothing for the defer wrapper

## template&lt;class T&gt; void cereal::epilogue (**JSONInputArchive** & , **NameValuePair**&lt; T &gt; const & ) \[inline]

Epilogue for NVPs for JSON archives. NVPs do not start or finish nodes - they just set up the names

## template&lt;class T&gt; void cereal::epilogue (**JSONOutputArchive** & , **DeferredData**&lt; T &gt; const & ) \[inline]

Epilogue for deferred for JSON archives. NVPs do not start or finish nodes - they just set up the names

## template&lt;class T&gt; void cereal::epilogue (**JSONOutputArchive** & , **NameValuePair**&lt; T &gt; const & ) \[inline]

Epilogue for NVPs for JSON archives. NVPs do not start or finish nodes - they just set up the names

## template&lt;class T&gt; void cereal::epilogue (**JSONOutputArchive** & , **SizeTag**&lt; T &gt; const & ) \[inline]

Epilogue for SizeTags for JSON archives. SizeTags are strictly ignored for JSON

## template&lt;class T, **traits::EnableIf**&lt;!std::is\_arithmetic&lt; T &gt;::value, !traits::has\_minimal\_base\_class\_serialization&lt; T, traits::has\_minimal\_output\_serialization, JSONOutputArchive &gt;::value, !traits::has\_minimal\_output\_serialization&lt; T, JSONOutputArchive &gt;::value &gt; = traits::sfinae&gt; void cereal::epilogue (**JSONOutputArchive** & ar, T const & ) \[inline]

Epilogue for all other types other for JSON archives (except minimal types). Finishes the node created in the prologue

Minimal types do not start or finish nodes

## template&lt;class T&gt; void cereal::prologue (**JSONOutputArchive** & , **DeferredData**&lt; T &gt; const & ) \[inline]

Prologue for deferred data for JSON archives. Do nothing for the defer wrapper

## template&lt;class T&gt; void cereal::prologue (**JSONOutputArchive** & , **NameValuePair**&lt; T &gt; const & ) \[inline]

Prologue for NVPs for JSON archives. NVPs do not start or finish nodes - they just set up the names

## template&lt;class T&gt; void cereal::prologue (**JSONOutputArchive** & ar, **SizeTag**&lt; T &gt; const & ) \[inline]

Prologue for SizeTags for JSON archives. SizeTags are strictly ignored for JSON, they just indicate that the current node should be made into an array

## template&lt;class T, **traits::EnableIf**&lt;!std::is\_arithmetic&lt; T &gt;::value, !traits::has\_minimal\_base\_class\_serialization&lt; T, traits::has\_minimal\_output\_serialization, JSONOutputArchive &gt;::value, !traits::has\_minimal\_output\_serialization&lt; T, JSONOutputArchive &gt;::value &gt; = traits::sfinae&gt; void cereal::prologue (**JSONOutputArchive** & ar, T const & ) \[inline]

Prologue for all other types for JSON archives (except minimal types). Starts a new node, named either automatically or by some NVP, that may be given data by the type about to be archived

Minimal types do not start or finish nodes

# [Author](#Author)

Generated automatically by Doxygen for cereal from the source code.

Mon Oct 26 2026 02:55:37 cereal

---

Document: json.hpp(3) from cereal 1.3.2-r7 (Chainguard OS)
Source: https://github.com/USCiLab/cereal
