.TH "cereal::JSONInputArchive" 3 "Sat Aug 29 2026 00:42:30" "cereal" \" -*- nroff -*- .ad l .nh .SH NAME cereal::JSONInputArchive \- An input archive designed to load data from JSON\&. .SH SYNOPSIS .br .PP .PP \fR#include \fP .PP Inherits \fBcereal::InputArchive< JSONInputArchive >\fP, and \fBcereal::traits::TextArchive\fP\&. .SS "Public Member Functions" .PP .RI "\fBCommon Functionality\fP" .br Common use cases for directly interacting with an \fBJSONInputArchive\fP .PP .in +1c .in +1c .ti -1c .RI "\fBJSONInputArchive\fP (std::istream &stream)" .br .RI "Construct, reading from the provided stream\&. " .ti -1c .RI "void \fBloadBinaryValue\fP (void *data, size_t size, const char *name=nullptr)" .br .RI "Loads some binary data, encoded as a base64 string\&. " .in -1c .in -1c Public Member Functions inherited from \fBcereal::InputArchive< JSONInputArchive >\fP .in +1c .ti -1c .RI "\fBInputArchive\fP (\fBJSONInputArchive\fP *const derived)" .br .RI "Construct the output archive\&. " .ti -1c .RI "\fBInputArchive\fP & \fBoperator=\fP (\fBInputArchive\fP const &)=delete" .br .ti -1c .RI "\fBJSONInputArchive\fP & \fBoperator()\fP (Types &&\&.\&.\&. args)" .br .RI "Serializes all passed in data\&. " .ti -1c .RI "void \fBserializeDeferments\fP ()" .br .RI "Serializes any data marked for deferment using defer\&. " .ti -1c .RI "std::shared_ptr< void > \fBgetSharedPointer\fP (std::uint32_t const id)" .br .RI "Retrieves a shared pointer given a unique key for it\&. " .ti -1c .RI "void \fBregisterSharedPointer\fP (std::uint32_t const id, std::shared_ptr< void > ptr)" .br .RI "Registers a shared pointer to its unique identifier\&. " .ti -1c .RI "std::string \fBgetPolymorphicName\fP (std::uint32_t const id)" .br .RI "Retrieves the string for a polymorphic type given a unique key for it\&. " .ti -1c .RI "void \fBregisterPolymorphicName\fP (std::uint32_t const id, std::string const &name)" .br .RI "Registers a polymorphic name string to its unique identifier\&. " .in -1c .in +1c .ti -1c .RI "\fBJSONInputArchive\fP & \fBoperator&\fP (T &&arg)" .br .RI "Serializes passed in data\&. " .in -1c .in +1c .ti -1c .RI "\fBJSONInputArchive\fP & \fBoperator>>\fP (T &&arg)" .br .RI "Serializes passed in data\&. " .in -1c Public Member Functions inherited from \fBcereal::detail::InputArchiveBase\fP .in +1c .ti -1c .RI "\fBInputArchiveBase\fP (InputArchiveBase &&) \fBCEREAL_NOEXCEPT\fP" .br .ti -1c .RI "InputArchiveBase & \fBoperator=\fP (InputArchiveBase &&) \fBCEREAL_NOEXCEPT\fP" .br .in -1c .SS "Internal Functionality" Functionality designed for use by those requiring control over the inner mechanisms of the \fBJSONInputArchive\fP .in +1c .ti -1c .RI "void \fBstartNode\fP ()" .br .RI "Starts a new node, going into its proper iterator\&. " .ti -1c .RI "void \fBfinishNode\fP ()" .br .RI "Finishes the most recently started node\&. " .ti -1c .RI "const char * \fBgetNodeName\fP () const" .br .RI "Retrieves the current node name\&. " .ti -1c .RI "void \fBsetNextName\fP (const char *name)" .br .RI "Sets the name for the next node created with startNode\&. " .in -1c .SS "Additional Inherited Members" .in +1c .ti -1c .RI "using \fBis_loading\fP" .br .RI "Indicates this archive is intended for loading\&. " .in -1c .in +1c .ti -1c .RI "using \fBis_saving\fP" .br .RI "Indicates this archive is not intended for saving\&. " .in -1c .SH "Detailed Description" .PP An input archive designed to load data from JSON\&. This archive uses RapidJSON to read in a JSON archive\&. .PP As with the output JSON archive, the preferred way to use this archive is in an RAII fashion, ensuring its destruction after all data has been read\&. .PP Input JSON should have been produced by the \fBJSONOutputArchive\fP\&. Data can only be added to dynamically sized containers (marked by JSON arrays) - the input archive will determine their size by looking at the number of child nodes\&. Only JSON originating from a \fBJSONOutputArchive\fP is officially supported, but data from other sources may work if properly formatted\&. .PP The \fBJSONInputArchive\fP does not require that nodes are loaded in the same order they were saved by \fBJSONOutputArchive\fP\&. Using name value pairs (NVPs), it is possible to load in an out of order fashion or otherwise skip/select specific nodes to load\&. .PP The default behavior of the input archive is to read sequentially starting with the first node and exploring its children\&. When a given NVP does not match the read in name for a node, the archive will search for that node at the current level and load it if it exists\&. After loading an out of order node, the archive will then proceed back to loading sequentially from its new position\&. .PP Consider this simple example where loading of some data is skipped: .PP .PP .nf // imagine the input file has someData(1\-9) saved in order at the top level node ar( someData1, someData2, someData3 ); // XML loads in the order it sees in the file ar( cereal::make_nvp( "hello", someData6 ) ); // NVP given does not // match expected NVP name, so we search // for the given NVP and load that value ar( someData7, someData8, someData9 ); // with no NVP given, loading resumes at its // current location, proceeding sequentially .fi .PP .SH "Constructor & Destructor Documentation" .PP .SS "cereal::JSONInputArchive::JSONInputArchive (std::istream & stream)\fR [inline]\fP" .PP Construct, reading from the provided stream\&. .PP \fBParameters\fP .RS 4 \fIstream\fP The stream to read from .RE .PP .SH "Member Function Documentation" .PP .SS "const char * cereal::JSONInputArchive::getNodeName () const\fR [inline]\fP" .PP Retrieves the current node name\&. .PP \fBReturns\fP .RS 4 nullptr if no name exists .RE .PP .SS "void cereal::JSONInputArchive::loadBinaryValue (void * data, size_t size, const char * name = \fRnullptr\fP)\fR [inline]\fP" .PP Loads some binary data, encoded as a base64 string\&. This will automatically start and finish a node to load the data, and can be called directly by users\&. .PP Note that this follows the same ordering rules specified in the class description in regards to loading in/out of order .SS "void cereal::JSONInputArchive::startNode ()\fR [inline]\fP" .PP Starts a new node, going into its proper iterator\&. This places an iterator for the next node to be parsed onto the iterator stack\&. If the next node is an array, this will be a value iterator, otherwise it will be a member iterator\&. .PP By default our strategy is to start with the document root node and then recursively iterate through all children in the order they show up in the document\&. We don't need to know NVPs to do this; we'll just blindly load in the order things appear in\&. .PP If we were given an NVP, we will search for it if it does not match our the name of the next node that would normally be loaded\&. This functionality is provided by search()\&. .SH "Author" .PP Generated automatically by Doxygen for cereal from the source code\&.