Zigbee Protocol Controller 1.6.0
json_helpers.hpp File Reference

Helper functions for nlohmann::json library. More...

#include "zap-types.h"
#include <nlohmann/json.hpp>

Go to the source code of this file.

Functions

bool get_bool_from_json (nlohmann::json &jsn, const std::string &key)
 Converts json payload (either boolean, string or integer) to bool value. This function is used because nlohmann::json library can't automatically convert string or numerical json payload to boolean value and it fails in such cases. More...
 
bool get_bool_from_json_array (nlohmann::json &jsn, size_t index)
 Converts json array element (either boolean, string or integer) to bool value. More...
 
nlohmann::json add_transitions_to_json_obj (const TransitionType *data_array, const uint8_t arr_size)
 The pointer to array of "TransitionType" structs couldn't be automatically converted to nlohmann::json object - so this function provides a manual conversion. More...
 
nlohmann::json add_extension_field_to_json_obj (const SExtensionFieldSetList *data_array, const uint8_t arr_size)
 The pointer to array of "SExtensionFieldSetList" structs couldn't be automatically converted to nlohmann::json object - so this function provides a manual conversion. More...
 

Detailed Description

Helper functions for nlohmann::json library.

Function Documentation

◆ add_extension_field_to_json_obj()

nlohmann::json add_extension_field_to_json_obj ( const SExtensionFieldSetList data_array,
const uint8_t  arr_size 
)

The pointer to array of "SExtensionFieldSetList" structs couldn't be automatically converted to nlohmann::json object - so this function provides a manual conversion.

Parameters
data_array- pointer to array of SExtensionFieldSetList structs that should be converted to json object
arr_size- the number of elements in data_array
Returns
nlohmann::json object.

◆ add_transitions_to_json_obj()

nlohmann::json add_transitions_to_json_obj ( const TransitionType data_array,
const uint8_t  arr_size 
)

The pointer to array of "TransitionType" structs couldn't be automatically converted to nlohmann::json object - so this function provides a manual conversion.

Parameters
data_array- pointer to array of TransitionType structs that should be converted to json object
arr_size- the number of elements in data_array
Returns
nlohmann::json object.

◆ get_bool_from_json()

bool get_bool_from_json ( nlohmann::json &  jsn,
const std::string &  key 
)

Converts json payload (either boolean, string or integer) to bool value. This function is used because nlohmann::json library can't automatically convert string or numerical json payload to boolean value and it fails in such cases.

Returns
Boolean value that represents the payload.

◆ get_bool_from_json_array()

bool get_bool_from_json_array ( nlohmann::json &  jsn,
size_t  index 
)

Converts json array element (either boolean, string or integer) to bool value.

Parameters
jsnJSON array to inspect (json::array())
indexIndex of the element to inspect
Returns
Boolean value that represents the value of the nth element.