GDAL
Public Member Functions | List of all members
CPLJSONDocument Class Reference

The CPLJSONDocument class Wrapper class around json-c library. More...

#include <cpl_json.h>

Public Member Functions

bool Save (const std::string &osPath) const
 Save json document at specified path.
 
std::string SaveAsString () const
 Return the json document as a serialized string.
 
CPLJSONObject GetRoot ()
 Get json document root object.
 
const CPLJSONObject GetRoot () const
 Get json document root object.
 
void SetRoot (const CPLJSONObject &oRoot)
 Set json document root object.
 
bool Load (const std::string &osPath)
 Load json document from file by provided path.
 
bool LoadMemory (const std::string &osStr)
 Load json document from memory buffer.
 
bool LoadMemory (const GByte *pabyData, int nLength=-1)
 Load json document from memory buffer.
 
bool LoadChunks (const std::string &osPath, size_t nChunkSize=16384, GDALProgressFunc pfnProgress=nullptr, void *pProgressArg=nullptr)
 Load json document from file using small chunks of data.
 
bool LoadUrl (const std::string &osUrl, const char *const *papszOptions, GDALProgressFunc pfnProgress=nullptr, void *pProgressArg=nullptr)
 Load json document from web.
 

Detailed Description

The CPLJSONDocument class Wrapper class around json-c library.

Member Function Documentation

◆ GetRoot() [1/2]

CPLJSONObject CPLJSONDocument::GetRoot ( )

Get json document root object.

Returns
CPLJSONObject class instance
Since
GDAL 2.3

◆ GetRoot() [2/2]

const CPLJSONObject CPLJSONDocument::GetRoot ( ) const

Get json document root object.

Returns
CPLJSONObject class instance
Since
GDAL 3.1

◆ Load()

bool CPLJSONDocument::Load ( const std::string &  osPath)

Load json document from file by provided path.

Parameters
osPathPath to json file.
Returns
true on success. If error occurred it can be received using CPLGetLastErrorMsg method.
Since
GDAL 2.3

◆ LoadChunks()

bool CPLJSONDocument::LoadChunks ( const std::string &  osPath,
size_t  nChunkSize = 16384,
GDALProgressFunc  pfnProgress = nullptr,
void *  pProgressArg = nullptr 
)

Load json document from file using small chunks of data.

Parameters
osPathPath to json document file.
nChunkSizeChunk size.
pfnProgressa function to report progress of the json data loading.
pProgressArgapplication data passed into progress function.
Returns
true on success. If error occurred it can be received using CPLGetLastErrorMsg method.
Since
GDAL 2.3

◆ LoadMemory() [1/2]

bool CPLJSONDocument::LoadMemory ( const GByte pabyData,
int  nLength = -1 
)

Load json document from memory buffer.

Parameters
pabyDataBuffer.data.
nLengthBuffer size.
Returns
true on success. If error occurred it can be received using CPLGetLastErrorMsg method.
Since
GDAL 2.3

◆ LoadMemory() [2/2]

bool CPLJSONDocument::LoadMemory ( const std::string &  osStr)

Load json document from memory buffer.

Parameters
osStrString
Returns
true on success. If error occurred it can be received using CPLGetLastErrorMsg method.
Since
GDAL 2.3

◆ LoadUrl()

bool CPLJSONDocument::LoadUrl ( const std::string &  osUrl,
const char *const *  papszOptions,
GDALProgressFunc  pfnProgress = nullptr,
void *  pProgressArg = nullptr 
)

Load json document from web.

Parameters
osUrlUrl to json document.
papszOptionsOption list as a NULL-terminated array of strings. May be NULL. The available keys are same for CPLHTTPFetch method. Additional key JSON_DEPTH define json parse depth. Default is 10.
pfnProgressa function to report progress of the json data loading.
pProgressArgapplication data passed into progress function.
Returns
true on success. If error occurred it can be received using CPLGetLastErrorMsg method.
Since
GDAL 2.3

◆ Save()

bool CPLJSONDocument::Save ( const std::string &  osPath) const

Save json document at specified path.

Parameters
osPathPath to save json document
Returns
true on success. If error occurred it can be received using CPLGetLastErrorMsg method.
Since
GDAL 2.3

◆ SaveAsString()

std::string CPLJSONDocument::SaveAsString ( ) const

Return the json document as a serialized string.

Returns
serialized document.
Since
GDAL 2.3

◆ SetRoot()

void CPLJSONDocument::SetRoot ( const CPLJSONObject oRoot)

Set json document root object.

Parameters
oRootCPLJSONObject root object
Since
GDAL 3.4

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