namespace json_converter

Overview

namespace json_converter {

// global functions

static PyObject* convertJsonToPyDict(const nlohmann::json& json);
static PyObject* convertJsonToPyList(const nlohmann::json& json);
static void generatePythonError(const std::string& errorMessage);
PyObject* convertJsonToPyObject(const nlohmann::json& json);

template <typename VECTOR_TYPE>
static nlohmann::json convertNumpyArrayHelper(const boost::python::numpy::ndarray& npArray);

template <typename BUILTIN_TYPE>
static bool compareDtype(np::dtype dtype);

nlohmann::json convertNumpyArrayToJson(PyObject* value);
static nlohmann::json convertPyListToJson(PyObject* value);
static nlohmann::json convertPyTupleToJson(PyObject* value);
static nlohmann::json convertPyDictToJson(PyObject* value);
static bool isNumpyInitialized();
nlohmann::json convertPyObjectToJson(PyObject* value);
void initNumpy();

} // namespace json_converter

Detailed Documentation

Global Functions

PyObject* convertJsonToPyObject(const nlohmann::json& json)

Converts given JSON object into a python object.

nlohmann::json convertPyObjectToJson(PyObject* value)

Converts given python object into a JSON object.

void initNumpy()

Initializes numpy array API for this module.

The function must be called before using the module. If it’s not done, some of the other functions in the module may fail with an exception. The function must be called after Py_Initialize().