Skip to content

Commit 025707d

Browse files
authored
Merge pull request #120 from dchanman/master
Add getPayloadBoolValue to redfishPayload.h
2 parents 6129706 + 2d24e5e commit 025707d

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

include/redfishPayload.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,17 @@ REDFISH_EXPORT char* getPayloadStringValue(redfishPayload* payload);
152152
* @return int contained in the payload or 0 if not a string entity
153153
*/
154154
REDFISH_EXPORT int getPayloadIntValue(redfishPayload* payload);
155+
/**
156+
* @brief Get the boolean value for the payload
157+
*
158+
* If the value of the payload is not a boolean, is_boolean will be set to false and the return value should be considered invalid. Otherwise return
159+
* the boolean contained in the payload.
160+
*
161+
* @param payload The payload to get the bool value of
162+
* @param is_boolean Pointer whose value will be set to true if the value of the payload is a boolean
163+
* @return bool contained in the payload
164+
*/
165+
REDFISH_EXPORT bool getPayloadBoolValue(redfishPayload* payload, bool* is_boolean);
155166

156167
/**
157168
* @brief Obtain the node in the payload identified by the specified nodeName

src/payload.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,13 @@ int getPayloadIntValue(redfishPayload* payload)
262262
return (int)json_integer_value(payload->json);
263263
}
264264

265+
bool getPayloadBoolValue(redfishPayload* payload, bool* is_boolean) {
266+
if (is_boolean != NULL) {
267+
*is_boolean = json_is_boolean(payload->json);
268+
}
269+
return json_boolean_value(payload->json);
270+
}
271+
265272
redfishPayload* getPayloadByNodeName(redfishPayload* payload, const char* nodeName)
266273
{
267274
json_t* value;

0 commit comments

Comments
 (0)