T4S4  19.1 C8540 A23673
Teamcenter Gateway for SAP S/4HANA API Reference
safejson Namespace Reference

Functions

 dict2json in
 Turn a data object represented as a Tcl dict into its JSON counterpart. More...
 
 string2json in
 Turn a string into a representation that can safely be embedded into a JSON object. More...
 

Detailed Description

This namespace contains functions used to convert data objects represented as Tcl dicts into their JSON counterparts and vice versa.

Function Documentation

◆ dict2json()

safejson::dict2json   in  

Turn a data object represented as a Tcl dict into its JSON counterpart.

Parameters
inthe dict be converted into JSON
Returns
the JSON representation

Keys are in the format NAME:TYPE where TYPE defines how the values are prepared before being converted into the JSON format.

string - The value is considered a string and will be enclosed in double quotes. Quotes and backslashes inside the string are escaped.

strings - The value is considered a list of strings and its items will be enclosed in double quotes. Quotes and backslashes inside the string are escaped.

safe - The value is considered a string and will be enclosed in double quotes. Quotes and backslashes inside the string are not escaped.

tohex - The value is considered a string and will be enclosed in double quotes after being converted into the base16 format.

allsafe - The value is considered a list of strings and its items will be enclosed in double quotes. Quotes and backslashes inside the string are not escaped.

tohex - The value is considered a string and will be enclosed in double quotes after being converted into the base16 format.

alltohex - The value is considered a list of strings and its items will be enclosed in double quotes after being converted into the base16 format.

num - The value is considered a number and will not be enclosed in double quotes.

bool - The value is considered a boolean literal and will not be enclosed in double quotes. 0, false, FALSE, and False will be translated to false, all other values to true.

nums - The value is considered a list of numbers and its items will not be enclosed in double quotes.

bools - The value is considered a list of boolean literals (see bool) and its items will not be enclosed in double quotes.

dict - The value is considered a dict and will recursively be prepared.

dicts - The value is considered a list of dicts and its items will be recursively prepared.

◆ string2json()

safejson::string2json   in  

Turn a string into a representation that can safely be embedded into a JSON object.

Parameters
inthe string to convert
Returns
a string to be embedded into a JSON object