Granada  1.54.0
Structured layer on top of C++ REST SDK for building server applications in C++. Granada implements sessions, server side plug-in framework, C++ OAuth 2.0 server, data storage access, server script running, server browsing.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
Functions
granada::util::json Namespace Reference

Functions

static std::string as_string (const web::json::value &json)
 
static std::string as_string (const web::json::value &json, const std::string &key)
 
static web::json::value as_object (const web::json::value &json, const std::string &key)
 
static web::json::value as_array (const web::json::value &json, const std::string &key)
 
static web::json::value first (const web::json::value &json)
 

Detailed Description

Utils for json manipulation.

Function Documentation

static web::json::value granada::util::json::as_array ( const web::json::value &  json,
const std::string &  key 
)
inlinestatic

Parse a JSON value field into JSON array, if the JSON value field is not a JSON array, returns an empty JSON array [].

Parameters
jsonJSON value containing the field to parse to JSON array.
keyKey of the field to parse to JSON array.
Returns
JSON array or empty JSON array.
static web::json::value granada::util::json::as_object ( const web::json::value &  json,
const std::string &  key 
)
inlinestatic

Parse a JSON value field into JSON object, if the JSON value field is not a JSON object, returns an empty JSON object {}.

Parameters
jsonJSON value containing the field to parse to JSON object.
keyKey of the field to parse to JSON object.
Returns
JSON object or empty JSON object.
static std::string granada::util::json::as_string ( const web::json::value &  json)
inlinestatic

Parse a JSON value into string and returns the string, if the JSON value is not a string, returns an empty string.

Parameters
jsonJSON value to parse to string.
Returns
String or empty string.
static std::string granada::util::json::as_string ( const web::json::value &  json,
const std::string &  key 
)
inlinestatic

Parse a JSON value field into string and returns the string, if the JSON value field is not a string, returns an empty string.

Parameters
jsonJSON value containing the field to parse to string.
keyKey of the field to parse to string.
Returns
String or empty string.
static web::json::value granada::util::json::first ( const web::json::value &  json)
static

Returns the first element of a JSON object or a JSON array. If there is no first element returns a null json value.

Parameters
jsonJSON to extract the first element.
Returns
First element, JSON value.