Static Public Member Functions | List of all members
BeJsonUtilities Struct Reference

#include <BeJsonUtilities.h>

Static Public Member Functions

static bool HasRequiredMembers (JsonValueCR valueObj, Utf8CP const *requiredMembers)
 Returns true if all required members are present on the specified Json::Value object. More...
 
static bool HasOnlyExpectedMembers (JsonValueCR valueObj, Utf8CP const *requiredMembers, Utf8CP const *optionalMembers)
 Returns true if all required members are present on the specified Json::Value object AND the only other members are within the specified set of optional members. More...
 
static Json::Value StringValueFromInt64 (int64_t lld)
 Returns a Json::stringValue representation of the specified Int64. More...
 
static uint64_t UInt64FromValue (JsonValueCR value, uint64_t defaultOnError=0)
 Returns a UInt64 value from a Json::Value that may be integral or string. More...
 
static int64_t Int64FromValue (JsonValueCR value, int64_t defaultOnError=0)
 Returns an Int64 value from a Json::Value that may be integral or string. More...
 
static DateTime DateTimeFromValue (JsonValueCR value)
 Parse standard ISO8601 date from string value. More...
 
static bool IsValidObject (Utf8CP objectName, JsonValueCR objectValue, Utf8CP const *requiredMembers, Utf8CP const *optionalMembers)
 Equivalent to HasRequiredMembers in production builds unless objectValue has a member named "debug". More...
 
static Utf8CP CStringFromStringValue (JsonValueCR stringValue, Utf8CP defaultCString)
 Equivalent to Json::Value::get + Json::Value::asCString with proper NULL / error handling. More...
 

Member Function Documentation

static Utf8CP CStringFromStringValue ( JsonValueCR  stringValue,
Utf8CP  defaultCString 
)
static

Equivalent to Json::Value::get + Json::Value::asCString with proper NULL / error handling.

If a null value or non-string value is encountered, then the specified default string is returned.

Parameters
[in]stringValuethe value that is expected to be a Json::stringValue
[in]defaultCStringthe string to return if stringValue is not actually a Json::stringValue or stringValue is null.
Returns
a pointer to the string within the stringValue or to the defaultCString parameter. Therefore, attention must be paid to the lifetime of stringValue and defaultCString.
static DateTime DateTimeFromValue ( JsonValueCR  value)
static

Parse standard ISO8601 date from string value.

Parameters
[in]valuecontaining ISO8601 date string
Returns
parsed DateTime or invalid DateTime if errors occurred
static bool HasOnlyExpectedMembers ( JsonValueCR  valueObj,
Utf8CP const *  requiredMembers,
Utf8CP const *  optionalMembers 
)
static

Returns true if all required members are present on the specified Json::Value object AND the only other members are within the specified set of optional members.

Note that this is a somewhat expensive method, so is intended for debugging JSON messages only.

Parameters
[in]valueObjthe Json::Value object to check
[in]requiredMembersThe required member names to test. Specified as a C-style array of Utf8CP strings with NULL as last entry.
[in]optionalMembersThe optional member names that may or may not be present. Specified as a C-style array of Utf8CP strings with NULL as last entry.
static bool HasRequiredMembers ( JsonValueCR  valueObj,
Utf8CP const *  requiredMembers 
)
static

Returns true if all required members are present on the specified Json::Value object.

Parameters
[in]valueObjthe Json::Value object to check
[in]requiredMembersThe member names to test. Specified as a C-style array of Utf8CP strings with NULL as last entry.
static int64_t Int64FromValue ( JsonValueCR  value,
int64_t  defaultOnError = 0 
)
static

Returns an Int64 value from a Json::Value that may be integral or string.

Parameters
[in]valuethe source Json::Value
[in]defaultOnErrorthe Int64 value to return if it is not possible to convert the source value to Int64.
static bool IsValidObject ( Utf8CP  objectName,
JsonValueCR  objectValue,
Utf8CP const *  requiredMembers,
Utf8CP const *  optionalMembers 
)
static

Equivalent to HasRequiredMembers in production builds unless objectValue has a member named "debug".

In this case, the behavior is similar to HasOnlyExpectedMembers except there is more extensive logging.

Parameters
[in]objectNamethe name used for logging purposes. Must not be NULL.
[in]objectValuethe Json::Value object to check
[in]requiredMembersThe required member names to test. Specified as a C-style array of Utf8CP strings with NULL as last entry.
[in]optionalMembersThe optional member names that may or may not be present. Specified as a C-style array of Utf8CP strings with NULL as last entry.
static Json::Value StringValueFromInt64 ( int64_t  lld)
static

Returns a Json::stringValue representation of the specified Int64.

static uint64_t UInt64FromValue ( JsonValueCR  value,
uint64_t  defaultOnError = 0 
)
static

Returns a UInt64 value from a Json::Value that may be integral or string.

Parameters
[in]valuethe source Json::Value
[in]defaultOnErrorthe UInt64 value to return if it is not possible to convert the source value to UInt64.

The documentation for this struct was generated from the following file:

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.