RADLib
RADical C++ application framework
RADCore::RADJsonDocument Class Reference

JSON document wrapper around a root RADJsonValue. More...

#include <RADCore.h>

Public Member Functions

 RADJsonDocument ()
 Creates a document with null root. More...
 
 RADJsonDocument (RADJsonValue root)
 Creates a document from root. More...
 
const RADJsonValueroot () const
 Returns const root value. More...
 
RADJsonValueroot ()
 Returns mutable root value. More...
 
std::string toJson (bool pretty=false) const
 Serializes root to JSON. More...
 
bool toFile (const std::string &path, bool pretty=true, std::string *error=nullptr) const
 Writes JSON to path. More...
 

Static Public Member Functions

static std::optional< RADJsonDocumentfromJson (const std::string &json, std::string *error=nullptr)
 Parses JSON text. More...
 
static std::optional< RADJsonDocumentfromFile (const std::string &path, std::string *error=nullptr)
 Loads and parses JSON from path. More...
 

Detailed Description

JSON document wrapper around a root RADJsonValue.

Constructor & Destructor Documentation

◆ RADJsonDocument() [1/2]

RADCore::RADJsonDocument::RADJsonDocument ( )

Creates a document with null root.

◆ RADJsonDocument() [2/2]

RADCore::RADJsonDocument::RADJsonDocument ( RADJsonValue  root)
explicit

Creates a document from root.

Member Function Documentation

◆ fromFile()

static std::optional<RADJsonDocument> RADCore::RADJsonDocument::fromFile ( const std::string &  path,
std::string *  error = nullptr 
)
static

Loads and parses JSON from path.

◆ fromJson()

static std::optional<RADJsonDocument> RADCore::RADJsonDocument::fromJson ( const std::string &  json,
std::string *  error = nullptr 
)
static

Parses JSON text.

◆ root() [1/2]

RADJsonValue& RADCore::RADJsonDocument::root ( )

Returns mutable root value.

◆ root() [2/2]

const RADJsonValue& RADCore::RADJsonDocument::root ( ) const

Returns const root value.

◆ toFile()

bool RADCore::RADJsonDocument::toFile ( const std::string &  path,
bool  pretty = true,
std::string *  error = nullptr 
) const

Writes JSON to path.

◆ toJson()

std::string RADCore::RADJsonDocument::toJson ( bool  pretty = false) const

Serializes root to JSON.


The documentation for this class was generated from the following file: