JSON encode functions.

Functions

EXTERNJSON int rtJsonEncAnyAttr (OSCTXT *pctxt, const OSRTDList *pvalue)
 This function encodes a list of OSAnyAttr attributes in which the name and value are given as a UTF-8 string.
EXTERNJSON int rtJsonEncIntValue (OSCTXT *pctxt, OSINT32 value)
 This function encodes a variable of the XSD integer type.
EXTERNJSON int rtJsonEncInt64Value (OSCTXT *pctxt, OSINT64 value)
 This function encodes a variable of the XSD integer type.
EXTERNJSON int rtJsonEncBase64StrValue (OSCTXT *pctxt, OSUINT32 nocts, const OSOCTET *value)
 This function encodes a variable of the XSD base64Binary type.
EXTERNJSON int rtJsonEncBoolValue (OSCTXT *pctxt, OSBOOL value)
 This function encodes a variable of the XSD boolean type.
EXTERNJSON int rtJsonEncGYear (OSCTXT *pctxt, const OSXSDDateTime *pvalue)
 This function encodes a numeric gYear value into a JSON string representation.
EXTERNJSON int rtJsonEncGYearMonth (OSCTXT *pctxt, const OSXSDDateTime *pvalue)
 This function encodes a numeric gYearMonth value into a JSON string representation.
EXTERNJSON int rtJsonEncGMonth (OSCTXT *pctxt, const OSXSDDateTime *pvalue)
 This function encodes a numeric gMonth value into a JSON string representation.
EXTERNJSON int rtJsonEncGMonthDay (OSCTXT *pctxt, const OSXSDDateTime *pvalue)
 This function encodes a numeric gMonthDay value into a JSON string representation.
EXTERNJSON int rtJsonEncGDay (OSCTXT *pctxt, const OSXSDDateTime *pvalue)
 This function encodes a numeric gDay value into a JSON string representation.
EXTERNJSON int rtJsonEncDate (OSCTXT *pctxt, const OSXSDDateTime *pvalue)
 This function encodes a variable of the XSD 'date' type as a string.
EXTERNJSON int rtJsonEncTime (OSCTXT *pctxt, const OSXSDDateTime *pvalue)
 This function encodes a variable of the XSD 'time' type as a JSON string.
EXTERNJSON int rtJsonEncDateTime (OSCTXT *pctxt, const OSXSDDateTime *pvalue)
 This function encodes a numeric date/time value into a string representation.
EXTERNJSON int rtJsonEncDecimalValue (OSCTXT *pctxt, OSREAL value, const OSDecimalFmt *pFmtSpec)
 This function encodes a value of the XSD decimal type.
EXTERNJSON int rtJsonEncDoubleValue (OSCTXT *pctxt, OSREAL value, const OSDoubleFmt *pFmtSpec)
 This function encodes a value of the XSD double or float type.
EXTERNJSON int rtJsonEncFloatValue (OSCTXT *pctxt, OSREAL value, const OSDoubleFmt *pFmtSpec)
 This function encodes a variable of the XSD float type.
EXTERNJSON int rtJsonEncHexStr (OSCTXT *pctxt, OSSIZE nocts, const OSOCTET *data)
 This function encodes a variable of the XSD hexBinary type.
EXTERNJSON int rtJsonEncBitStrValue (OSCTXT *pctxt, OSUINT32 nbits, const OSOCTET *data)
 This function encodes a variable of the ASN.1 Bit string type.
EXTERNJSON int rtJsonEncIndent (OSCTXT *pctxt)
 This function adds indentation whitespace to the output stream.
EXTERNJSON int rtJsonEncStringObject (OSCTXT *pctxt, const OSUTF8CHAR *name, const OSUTF8CHAR *value)
 This function encodes a JSON object containing a string value.
EXTERNJSON int rtJsonEncStringObject2 (OSCTXT *pctxt, const OSUTF8CHAR *name, size_t nameLen, const OSUTF8CHAR *value, size_t valueLen)
 This function encodes a JSON object containing a string value.
EXTERNJSON int rtJsonEncStringPair (OSCTXT *pctxt, const OSUTF8CHAR *name, const OSUTF8CHAR *value)
 This function encodes a name/value pair.
EXTERNJSON int rtJsonEncStringPair2 (OSCTXT *pctxt, const OSUTF8CHAR *name, size_t nameLen, const OSUTF8CHAR *value, size_t valueLen)
 This function encodes a name/value pair.
EXTERNJSON int rtJsonEncStringValue (OSCTXT *pctxt, const OSUTF8CHAR *value)
 This function encodes a variable of the XSD string type.
EXTERNJSON int rtJsonEncStringValue2 (OSCTXT *pctxt, const OSUTF8CHAR *value, size_t valueLen)
 This function encodes a variable of the XSD string type.
EXTERNJSON int rtJsonEncStringNull (OSCTXT *pctxt)
 This function encodes an asn.1 NULL type as string.
EXTERNJSON int rtJsonEncStringRaw (OSCTXT *pctxt, const OSUTF8CHAR *value)
 This function encodes a raw string without any quotation.
EXTERNJSON int rtJsonEncUnicodeData (OSCTXT *pctxt, const OSUNICHAR *value, OSSIZE nchars)
 This function encodes a variable that contains UCS-2 / UTF-16 characters.
EXTERNJSON int rtJsonEncUCS4Data (OSCTXT *pctxt, const OS32BITCHAR *value, OSSIZE nchars)
 This function encodes a variable that contains UCS-4 / UTF-32 characters.
EXTERNJSON int rtJsonEncUIntValue (OSCTXT *pctxt, OSUINT32 value)
 This function encodes a variable of the XSD unsigned integer type.
EXTERNJSON int rtJsonEncUInt64Value (OSCTXT *pctxt, OSUINT64 value)
 This function encodes a variable of the XSD integer type.
EXTERNJSON int rtJsonEncStartObject (OSCTXT *pctxt, const OSUTF8CHAR *name, OSBOOL noComma)
 This function encodes the beginning of a JSON object.
EXTERNJSON int rtJsonEncEndObject (OSCTXT *pctxt)
 This function encodes the end of a JSON object.
EXTERNJSON int rtJsonEncBetweenObject (OSCTXT *pctxt)
 This function encodes the characters separating the JSON name and value.

Function Documentation

EXTERNJSON int rtJsonEncAnyAttr ( OSCTXT *  pctxt,
const OSRTDList *  pvalue 
)

This function encodes a list of OSAnyAttr attributes in which the name and value are given as a UTF-8 string.

Parameters:
pctxt Pointer to context block structure.
pvalue List of attributes.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTERNJSON int rtJsonEncBase64StrValue ( OSCTXT *  pctxt,
OSUINT32  nocts,
const OSOCTET *  value 
)

This function encodes a variable of the XSD base64Binary type.

Parameters:
pctxt Pointer to context block structure.
nocts Number of octets in the value string.
value Value to be encoded.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTERNJSON int rtJsonEncBetweenObject ( OSCTXT *  pctxt  ) 

This function encodes the characters separating the JSON name and value.

Parameters:
pctxt Pointer to context block structure.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTERNJSON int rtJsonEncBitStrValue ( OSCTXT *  pctxt,
OSUINT32  nbits,
const OSOCTET *  data 
)

This function encodes a variable of the ASN.1 Bit string type.

Parameters:
pctxt Pointer to context block structure.
nbits Number of bits in the value string.
data Value to be encoded.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTERNJSON int rtJsonEncBoolValue ( OSCTXT *  pctxt,
OSBOOL  value 
)

This function encodes a variable of the XSD boolean type.

Parameters:
pctxt Pointer to context block structure.
value Boolean value to be encoded.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTERNJSON int rtJsonEncDate ( OSCTXT *  pctxt,
const OSXSDDateTime *  pvalue 
)

This function encodes a variable of the XSD 'date' type as a string.

This version of the function is used to encode an OSXSDDateTime value into CCYY-MM-DD format.

Parameters:
pctxt Pointer to context block structure.
pvalue OSXSDDateTime type pointer points to a OSXSDDateTime value to be encoded.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTERNJSON int rtJsonEncDateTime ( OSCTXT *  pctxt,
const OSXSDDateTime *  pvalue 
)

This function encodes a numeric date/time value into a string representation.

Parameters:
pctxt Pointer to context block structure.
pvalue Pointer to value to be encoded.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTERNJSON int rtJsonEncDecimalValue ( OSCTXT *  pctxt,
OSREAL  value,
const OSDecimalFmt *  pFmtSpec 
)

This function encodes a value of the XSD decimal type.

Parameters:
pctxt Pointer to context block structure.
value Value to be encoded.
pFmtSpec Pointer to format specification structure.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTERNJSON int rtJsonEncDoubleValue ( OSCTXT *  pctxt,
OSREAL  value,
const OSDoubleFmt *  pFmtSpec 
)

This function encodes a value of the XSD double or float type.

Parameters:
pctxt Pointer to context block structure.
value Value to be encoded.
pFmtSpec Pointer to format specification structure.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTERNJSON int rtJsonEncEndObject ( OSCTXT *  pctxt  ) 

This function encodes the end of a JSON object.

Parameters:
pctxt Pointer to context block structure.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTERNJSON int rtJsonEncFloatValue ( OSCTXT *  pctxt,
OSREAL  value,
const OSDoubleFmt *  pFmtSpec 
)

This function encodes a variable of the XSD float type.

Parameters:
pctxt Pointer to context block structure.
value Value to be encoded.
pFmtSpec Pointer to format specification structure.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTERNJSON int rtJsonEncGDay ( OSCTXT *  pctxt,
const OSXSDDateTime *  pvalue 
)

This function encodes a numeric gDay value into a JSON string representation.

Parameters:
pctxt Pointer to context block structure.
pvalue Pointer to value to be encoded.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTERNJSON int rtJsonEncGMonth ( OSCTXT *  pctxt,
const OSXSDDateTime *  pvalue 
)

This function encodes a numeric gMonth value into a JSON string representation.

Parameters:
pctxt Pointer to context block structure.
pvalue Pointer to value to be encoded.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTERNJSON int rtJsonEncGMonthDay ( OSCTXT *  pctxt,
const OSXSDDateTime *  pvalue 
)

This function encodes a numeric gMonthDay value into a JSON string representation.

Parameters:
pctxt Pointer to context block structure.
pvalue Pointer to value to be encoded.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTERNJSON int rtJsonEncGYear ( OSCTXT *  pctxt,
const OSXSDDateTime *  pvalue 
)

This function encodes a numeric gYear value into a JSON string representation.

Parameters:
pctxt Pointer to context block structure.
pvalue Pointer to value to be encoded.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTERNJSON int rtJsonEncGYearMonth ( OSCTXT *  pctxt,
const OSXSDDateTime *  pvalue 
)

This function encodes a numeric gYearMonth value into a JSON string representation.

Parameters:
pctxt Pointer to context block structure.
pvalue Pointer to value to be encoded.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTERNJSON int rtJsonEncHexStr ( OSCTXT *  pctxt,
OSSIZE  nocts,
const OSOCTET *  data 
)

This function encodes a variable of the XSD hexBinary type.

Parameters:
pctxt Pointer to context block structure.
nocts Number of octets in the value string.
data Value to be encoded.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTERNJSON int rtJsonEncIndent ( OSCTXT *  pctxt  ) 

This function adds indentation whitespace to the output stream.

The amount of indentation to add is determined by the level member variable in the context structure and the OSXMLINDENT constant value.

Parameters:
pctxt Pointer to context block structure.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTERNJSON int rtJsonEncInt64Value ( OSCTXT *  pctxt,
OSINT64  value 
)

This function encodes a variable of the XSD integer type.

This version of the function is used for 64-bit integer values.

Parameters:
pctxt Pointer to context block structure.
value Value to be encoded.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTERNJSON int rtJsonEncIntValue ( OSCTXT *  pctxt,
OSINT32  value 
)

This function encodes a variable of the XSD integer type.

Parameters:
pctxt Pointer to context block structure.
value Value to be encoded.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTERNJSON int rtJsonEncStartObject ( OSCTXT *  pctxt,
const OSUTF8CHAR *  name,
OSBOOL  noComma 
)

This function encodes the beginning of a JSON object.

Parameters:
pctxt Pointer to context block structure.
name Object name token to be encoded.
noComma If TRUE do not print comma at end of line in output.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTERNJSON int rtJsonEncStringNull ( OSCTXT *  pctxt  ) 

This function encodes an asn.1 NULL type as string.

Parameters:
pctxt Pointer to context block structure.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTERNJSON int rtJsonEncStringObject ( OSCTXT *  pctxt,
const OSUTF8CHAR *  name,
const OSUTF8CHAR *  value 
)

This function encodes a JSON object containing a string value.

Parameters:
pctxt Pointer to context block structure.
name Name token to be encoded.
value Value as a character string to be encoded.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTERNJSON int rtJsonEncStringObject2 ( OSCTXT *  pctxt,
const OSUTF8CHAR *  name,
size_t  nameLen,
const OSUTF8CHAR *  value,
size_t  valueLen 
)

This function encodes a JSON object containing a string value.

Parameters:
pctxt Pointer to context block structure.
name Name token to be encoded.
nameLen Length of the name token to be encoded.
value Value as a character string to be encoded.
valueLen Length of the value to be encoded.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTERNJSON int rtJsonEncStringPair ( OSCTXT *  pctxt,
const OSUTF8CHAR *  name,
const OSUTF8CHAR *  value 
)

This function encodes a name/value pair.

The value is a character string.

Parameters:
pctxt Pointer to context block structure.
name Name token to be encoded.
value Value as a character string to be encoded.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTERNJSON int rtJsonEncStringPair2 ( OSCTXT *  pctxt,
const OSUTF8CHAR *  name,
size_t  nameLen,
const OSUTF8CHAR *  value,
size_t  valueLen 
)

This function encodes a name/value pair.

The value is a character string.

Parameters:
pctxt Pointer to context block structure.
name Name token to be encoded.
nameLen Length of the name token to be encoded.
value Value as a character string to be encoded.
valueLen Length of the value to be encoded.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTERNJSON int rtJsonEncStringRaw ( OSCTXT *  pctxt,
const OSUTF8CHAR *  value 
)

This function encodes a raw string without any quotation.

Parameters:
pctxt Pointer to context block structure.
value String value to be written.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTERNJSON int rtJsonEncStringValue ( OSCTXT *  pctxt,
const OSUTF8CHAR *  value 
)

This function encodes a variable of the XSD string type.

Parameters:
pctxt Pointer to context block structure.
value XML string value to be encoded.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTERNJSON int rtJsonEncStringValue2 ( OSCTXT *  pctxt,
const OSUTF8CHAR *  value,
size_t  valueLen 
)

This function encodes a variable of the XSD string type.

Parameters:
pctxt Pointer to context block structure.
value XML string value to be encoded.
valueLen Length of the XML string to be encoded.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTERNJSON int rtJsonEncTime ( OSCTXT *  pctxt,
const OSXSDDateTime *  pvalue 
)

This function encodes a variable of the XSD 'time' type as a JSON string.

Parameters:
pctxt Pointer to context block structure.
pvalue OSXSDDateTime type pointer points to a OSXSDDateTime value to be encoded.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTERNJSON int rtJsonEncUCS4Data ( OSCTXT *  pctxt,
const OS32BITCHAR *  value,
OSSIZE  nchars 
)

This function encodes a variable that contains UCS-4 / UTF-32 characters.

Parameters:
pctxt Pointer to context block structure.
value UCS-4 characters to be encoded.
nchars Number of characters to be encoded.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTERNJSON int rtJsonEncUInt64Value ( OSCTXT *  pctxt,
OSUINT64  value 
)

This function encodes a variable of the XSD integer type.

This version of the function is used when constraints cause an unsigned 64-bit integer variable to be used.

Parameters:
pctxt Pointer to context block structure.
value Value to be encoded.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTERNJSON int rtJsonEncUIntValue ( OSCTXT *  pctxt,
OSUINT32  value 
)

This function encodes a variable of the XSD unsigned integer type.

Parameters:
pctxt Pointer to context block structure.
value Value to be encoded.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.
EXTERNJSON int rtJsonEncUnicodeData ( OSCTXT *  pctxt,
const OSUNICHAR *  value,
OSSIZE  nchars 
)

This function encodes a variable that contains UCS-2 / UTF-16 characters.

Parameters:
pctxt Pointer to context block structure.
value UCS-2 characters to be encoded.
nchars Number of Unicode characters to be encoded.
Returns:
Completion status of operation:
  • 0 = success,
  • negative return value is error.