% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/serialization.R
\name{JSONCreation}
\alias{JSONCreation}
\alias{createCppJson}
\alias{createCppJsonFile}
\alias{createCppJsonString}
\title{JSON Creation Routines}
\usage{
createCppJson()

createCppJsonFile(json_filename)

createCppJsonString(json_string)
}
\arguments{
\item{json_filename}{Name of JSON file to read. Must end in \code{.json}.}

\item{json_string}{JSON string}
}
\value{
Each of the functions in this group returns a \code{CppJson} object.
}
\description{
The \link{CppJson} class wraps an external pointer to C++ JSON object for a seamless R serialization interface.
This function group provides several utilities for creating \link{CppJson} objects: from scratch (i.e. initializing an empty JSON object),
from a JSON file, or from a string that parses to valid JSON.

\code{createCppJson} creates a new (empty) \link{CppJson} object. \code{createCppJsonFile} creates and populates a \link{CppJson} object from data in a JSON file.
\code{createCppJsonString} creates and populates a \link{CppJson} object from a JSON string.

These functions are intended for advanced use cases in which users require detailed control of sampling algorithms and data structures.
Minimal input validation and error checks are performed -- users are responsible for providing the correct inputs.
For tutorials on the "proper" usage of the stochtree's advanced workflow, we provide several vignettes at \url{https://stochtree.ai/}
}
\examples{
example_vec <- runif(10)
example_json <- createCppJson()
example_json$add_vector("myvec", example_vec)
tmpjson <- tempfile(fileext = ".json")
example_json$save_file(file.path(tmpjson))
example_json_roundtrip <- createCppJsonFile(file.path(tmpjson))
unlink(tmpjson)
example_json_string <- example_json$return_json_string()
example_json_roundtrip <- createCppJsonString(example_json_string)

}
