| helics 3.6.1

Classes | Namespaces | Functions
JsonProcessingFunctions.hpp File Reference
`#include "../core/helicsTime.hpp"`
`#include <functional>`
`#include <nlohmann/json.hpp>`
`#include <string>`
`#include <string_view>`

Go to the source code of this file.

## Classes
class | helics::fileops::JsonBuffer
class | helics::fileops::JsonStorage

## Namespaces
| helics
| the main namespace for the helics co-simulation library User functions will be in the helics namespace with internal functions possible in a lower level namespace

## Functions
bool | helics::fileops::hasJsonExtension (std::string_view jsonString)
bool | helics::fileops::looksLikeConfigJson (std::string_view jsonString)
nlohmann::json | helics::fileops::loadJson (const std::string &jsonString)
nlohmann::json | helics::fileops::loadJsonStr (std::string_view jsonString)
helics::Time | helics::fileops::loadJsonTime (const nlohmann::json &timeElement, time_units defaultUnits)
std::string | helics::fileops::getName (const nlohmann::json &element)
std::string | helics::fileops::generateJsonString (const nlohmann::json &block, bool hexConvert)
std::string | helics::fileops::JsonAsString (const nlohmann::json &element)
std::string | helics::fileops::getOrDefault (const nlohmann::json &element, const std::string &key, std::string_view defVal)
double | helics::fileops::getOrDefault (const nlohmann::json &element, const std::string &key, double defVal)
bool | helics::fileops::getOrDefault (const nlohmann::json &element, const std::string &key, bool defVal)
int64_t | helics::fileops::getOrDefault (const nlohmann::json &element, const std::string &key, int64_t defVal)
bool | helics::fileops::callIfMember (const nlohmann::json &element, const std::string &key, const std::function< void(const std::string &, helics::Time)> &call)
bool | helics::fileops::callIfMember (const nlohmann::json &element, const std::string &key, const std::function< void(const std::string &, bool)> &call)
bool | helics::fileops::callIfMember (const nlohmann::json &element, const std::string &key, const std::function< void(const std::string &, int)> &call)
bool | helics::fileops::callIfMember (const nlohmann::json &element, const std::string &key, const std::function< void(const std::string &)> &call)
void | helics::fileops::replaceIfMember (const nlohmann::json &element, const std::string &key, helics::Time &timeVal)
void | helics::fileops::replaceIfMember (const nlohmann::json &element, const std::string &key, std::string &sval)
void | helics::fileops::replaceIfMember (const nlohmann::json &element, const std::string &key, bool &bval)
void | helics::fileops::replaceIfMember (const nlohmann::json &element, const std::string &key, int &sval)
void | helics::fileops::replaceIfMember (const nlohmann::json &element, const std::string &key, double &sval)

## Detailed Description

functions related to loading and evaluating JSON files and helper functions for reading them using the jsoncpp library

## Function Documentation

## ◆ generateJsonString()

std::string helics::fileops::generateJsonString | ( | const nlohmann::json & | block,
|  | bool | hexConvert = `true`
| ) |  |

generate a Json String

## ◆ getName()

std::string helics::fileops::getName | ( | const nlohmann::json & | element | ) |

get a name or key from the element

## ◆ hasJsonExtension()

bool helics::fileops::hasJsonExtension | ( | std::string_view | jsonString | ) |

check if the file has a valid JSON extension

## ◆ loadJson()

nlohmann::json helics::fileops::loadJson | ( | const std::string & | jsonString | ) |

load a JSON string or filename that points to a JSON file and return a nlohmann::json to the root object

## ◆ loadJsonStr()

nlohmann::json helics::fileops::loadJsonStr | ( | std::string_view | jsonString | ) |

load a JSON object in a string

## ◆ loadJsonTime()

helics::Time helics::fileops::loadJsonTime | ( | const nlohmann::json & | timeElement,
|  | time_units | defaultUnits
| ) |  |

read a time from a JSON value element

## ◆ looksLikeConfigJson()

bool helics::fileops::looksLikeConfigJson | ( | std::string_view | jsonString | ) |

check if the string looks like a possible config object in json format