Rosetta  2018.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Namespaces | Functions
json_utilities.hh File Reference

bag of utility functions for nlohmann::json (the one at external/include/json.hpp) More...

#include <json.hpp>
#include <platform/types.hh>
#include <string>

Namespaces

 utility
 unresizable vector whose size is known at compile time, which may be allocated on the stack, and which indexes from 0.
 
 utility::json
 

Functions

void utility::json::verify_present_exactly_once (nlohmann::json const &json, std::string const &element_name)
 verifies that the element is present exactly once. returns at all if true; throws utility_exist otherwise More...
 
void utility::json::extract_boolean_from_json (nlohmann::json const &json, std::string const &bool_name, bool &return_bool)
 utility function - verifies that a particular boolean is in the json exactly once More...
 
void utility::json::extract_number_from_json (nlohmann::json const &json, std::string const &number_name, platform::Real &return_number)
 utility function - verifies that a particular numeric value is in the json exactly once. Note JSON spec does not discriminate float vs int; we use floating point here, and your ints will be ok. More...
 
void utility::json::extract_nonempty_string_from_json (nlohmann::json const &json, std::string const &string_name, std::string &return_string)
 utility function - verifies that a particular string is in the json exactly once, and is nonempty More...
 
void utility::json::extract_nonempty_array_from_json (nlohmann::json const &json, std::string const &array_name, nlohmann::json &return_array)
 utility function - verifies that a particular json array is in the json exactly once, and is nonempty More...
 
void utility::json::extract_nonempty_object_from_json (nlohmann::json const &json, std::string const &object_name, nlohmann::json &return_object)
 utility function - verifies that a particular json object is in the json exactly once, and is nonempty More...
 

Detailed Description

bag of utility functions for nlohmann::json (the one at external/include/json.hpp)

These utility functions offer "safe access" to json - it checks that the element is present exactly once and returns-by-reference the contents. This uses Rosetta-type exceptions/exits to do so.

Author
Steven Lewis (smlew.nosp@m.i@gm.nosp@m.ail.c.nosp@m.om)