ppforest2 v0.1.0
Projection Pursuit Decision Trees and Random Forests
Loading...
Searching...
No Matches
ppforest2::io::json Namespace Reference

Functions

std::string ensure_extension (std::string const &path)
 Ensure a file path ends with the ".json" extension.
 
nlohmann::json read_file (std::string const &path)
 Read a JSON file and parse its contents.
 
void write_file (nlohmann::json const &data, std::string const &path)
 Write a JSON object to a file (pretty-printed with indent 2).
 

Function Documentation

◆ ensure_extension()

std::string ppforest2::io::json::ensure_extension ( std::string const & path)

Ensure a file path ends with the ".json" extension.

Parameters
pathThe original file path.
Returns
The path with ".json" appended if it was missing.

◆ read_file()

nlohmann::json ppforest2::io::json::read_file ( std::string const & path)

Read a JSON file and parse its contents.

Parameters
pathThe input file path.
Returns
The parsed JSON object.

◆ write_file()

void ppforest2::io::json::write_file ( nlohmann::json const & data,
std::string const & path )

Write a JSON object to a file (pretty-printed with indent 2).

Parameters
dataThe JSON object to serialize.
pathThe output file path.