T4EA  18.1 C7177 A20283
Teamcenter Gateway for Enterprise Applications 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, bool - The value is considered a number or a boolean literal resp. and will not be enclosed in double quotes.

nums, bools - The value is considered a list of number or boolean literals resp. 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.

References dict2json(), string2json(), and tpco_scanHEX16().

Referenced by dict2json().

◆ 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

Referenced by dict2json().