dict_to_jsonT_dict_to_jsonDictToJsonDictToJsondict_to_json (Operator)

Name

dict_to_jsonT_dict_to_jsonDictToJsonDictToJsondict_to_json — Transform a dictionary into a JSON string.

Signature

dict_to_json( : : DictHandle, GenParamName, GenParamValue : JsonString)

Herror T_dict_to_json(const Htuple DictHandle, const Htuple GenParamName, const Htuple GenParamValue, Htuple* JsonString)

void DictToJson(const HTuple& DictHandle, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* JsonString)

static HTuple HDict::DictToJson(const HDictArray& DictHandle, const HTuple& GenParamName, const HTuple& GenParamValue)

HString HDict::DictToJson(const HString& GenParamName, const HString& GenParamValue) const

HString HDict::DictToJson(const char* GenParamName, const char* GenParamValue) const

HString HDict::DictToJson(const wchar_t* GenParamName, const wchar_t* GenParamValue) const   (Windows only)

static void HOperatorSet.DictToJson(HTuple dictHandle, HTuple genParamName, HTuple genParamValue, out HTuple jsonString)

static HTuple HDict.DictToJson(HDict[] dictHandle, HTuple genParamName, HTuple genParamValue)

string HDict.DictToJson(string genParamName, string genParamValue)

def dict_to_json(dict_handle: MaybeSequence[HHandle], gen_param_name: MaybeSequence[str], gen_param_value: MaybeSequence[Union[int, float, str]]) -> Sequence[str]

def dict_to_json_s(dict_handle: MaybeSequence[HHandle], gen_param_name: MaybeSequence[str], gen_param_value: MaybeSequence[Union[int, float, str]]) -> str

Description

dict_to_jsondict_to_jsonDictToJsonDictToJsonDictToJsondict_to_json transforms the dictionary passed in DictHandleDictHandleDictHandleDictHandledictHandledict_handle into a JSON string and returns that string in JsonStringJsonStringJsonStringJsonStringjsonStringjson_string.

Several optional parameters can be set that control the creation of the JSON strings. Those parameters can be set via GenParamNameGenParamNameGenParamNameGenParamNamegenParamNamegen_param_name and GenParamValueGenParamValueGenParamValueGenParamValuegenParamValuegen_param_value and are described in the documentation of write_dictwrite_dictWriteDictWriteDictWriteDictwrite_dict:

dict_to_jsondict_to_jsonDictToJsonDictToJsonDictToJsondict_to_json can transform several dictionaries at once. For this, DictHandleDictHandleDictHandleDictHandledictHandledict_handle must contain a tuple of dictionaries. The output JsonStringJsonStringJsonStringJsonStringjsonStringjson_string will then contain one string per input dictionary.

Execution Information

Parameters

DictHandleDictHandleDictHandleDictHandledictHandledict_handle (input_control)  dict(-array) HDict, HTupleMaybeSequence[HHandle]HTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Dictionary handle.

GenParamNameGenParamNameGenParamNameGenParamNamegenParamNamegen_param_name (input_control)  attribute.name(-array) HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)

Name of the generic parameter.

Default value: []

List of values: 'compact_json'"compact_json""compact_json""compact_json""compact_json""compact_json", 'raise_error_if_content_not_serializable'"raise_error_if_content_not_serializable""raise_error_if_content_not_serializable""raise_error_if_content_not_serializable""raise_error_if_content_not_serializable""raise_error_if_content_not_serializable", 'use_json_arrays'"use_json_arrays""use_json_arrays""use_json_arrays""use_json_arrays""use_json_arrays"

GenParamValueGenParamValueGenParamValueGenParamValuegenParamValuegen_param_value (input_control)  attribute.name(-array) HTupleMaybeSequence[Union[int, float, str]]HTupleHtuple (string / integer / real) (string / int / long / double) (HString / Hlong / double) (char* / Hlong / double)

Value of the generic parameter.

Default value: []

Suggested values: 'true'"true""true""true""true""true", 'false'"false""false""false""false""false"

JsonStringJsonStringJsonStringJsonStringjsonStringjson_string (output_control)  string(-array) HTupleSequence[str]HTupleHtuple (string) (string) (HString) (char*)

String in JSON format.

Example (HDevelop)

dict_to_json (dict{foo: 'bar', bar: [0:2]}, [], [], JSONString)

Result

If the parameters are valid, the operator dict_to_jsondict_to_jsonDictToJsonDictToJsonDictToJsondict_to_json returns the value TRUE. If necessary an exception is raised.

Possible Predecessors

create_dictcreate_dictCreateDictCreateDictCreateDictcreate_dict, read_dictread_dictReadDictReadDictReadDictread_dict, json_to_dictjson_to_dictJsonToDictJsonToDictJsonToDictjson_to_dict

Possible Successors

json_to_dictjson_to_dictJsonToDictJsonToDictJsonToDictjson_to_dict

Alternatives

read_dictread_dictReadDictReadDictReadDictread_dict, create_dictcreate_dictCreateDictCreateDictCreateDictcreate_dict

See also

json_to_dictjson_to_dictJsonToDictJsonToDictJsonToDictjson_to_dict, read_dictread_dictReadDictReadDictReadDictread_dict, write_dictwrite_dictWriteDictWriteDictWriteDictwrite_dict, serialize_handleserialize_handleSerializeHandleSerializeHandleSerializeHandleserialize_handle, deserialize_handledeserialize_handleDeserializeHandleDeserializeHandleDeserializeHandledeserialize_handle, copy_dictcopy_dictCopyDictCopyDictCopyDictcopy_dict

Module

Foundation