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
Description
dict_to_jsondict_to_jsonDictToJsonDictToJsondict_to_json
transforms the dictionary passed in
DictHandleDictHandleDictHandledictHandledict_handle
into a JSON string and returns that string
in JsonStringJsonStringJsonStringjsonStringjson_string
.
Several optional parameters can be set that control the creation of
the JSON strings.
Those parameters can be set via GenParamNameGenParamNameGenParamNamegenParamNamegen_param_name
and GenParamValueGenParamValueGenParamValuegenParamValuegen_param_value
and are described in the documentation of
write_dictwrite_dictWriteDictWriteDictwrite_dict
:
-
'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",
-
'compact_json'"compact_json""compact_json""compact_json""compact_json",
-
'use_json_arrays'"use_json_arrays""use_json_arrays""use_json_arrays""use_json_arrays".
dict_to_jsondict_to_jsonDictToJsonDictToJsondict_to_json
can transform several dictionaries at once.
For this, DictHandleDictHandleDictHandledictHandledict_handle
must contain a tuple of dictionaries.
The output JsonStringJsonStringJsonStringjsonStringjson_string
will then contain one string
per input dictionary.
Execution Information
- Multithreading type: independent (runs in parallel even with exclusive operators).
- Multithreading scope: global (may be called from any thread).
- Processed without parallelization.
Parameters
DictHandleDictHandleDictHandledictHandledict_handle
(input_control) dict(-array) →
HDict, HTupleMaybeSequence[HHandle]HTupleHtuple (handle) (IntPtr) (HHandle) (handle)
Dictionary handle.
GenParamNameGenParamNameGenParamNamegenParamNamegen_param_name
(input_control) attribute.name(-array) →
HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)
Name of the generic parameter.
Default:
[]
List of values:
'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", 'use_json_arrays'"use_json_arrays""use_json_arrays""use_json_arrays""use_json_arrays"
GenParamValueGenParamValueGenParamValuegenParamValuegen_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:
[]
Suggested values:
'true'"true""true""true""true", 'false'"false""false""false""false"
JsonStringJsonStringJsonStringjsonStringjson_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_jsonDictToJsonDictToJsondict_to_json
returns
the value 2 (
H_MSG_TRUE)
. If necessary an exception is raised.
Possible Predecessors
create_dictcreate_dictCreateDictCreateDictcreate_dict
,
read_dictread_dictReadDictReadDictread_dict
,
json_to_dictjson_to_dictJsonToDictJsonToDictjson_to_dict
Possible Successors
json_to_dictjson_to_dictJsonToDictJsonToDictjson_to_dict
Alternatives
read_dictread_dictReadDictReadDictread_dict
,
create_dictcreate_dictCreateDictCreateDictcreate_dict
See also
json_to_dictjson_to_dictJsonToDictJsonToDictjson_to_dict
,
read_dictread_dictReadDictReadDictread_dict
,
write_dictwrite_dictWriteDictWriteDictwrite_dict
,
serialize_handleserialize_handleSerializeHandleSerializeHandleserialize_handle
,
deserialize_handledeserialize_handleDeserializeHandleDeserializeHandledeserialize_handle
,
copy_dictcopy_dictCopyDictCopyDictcopy_dict
Module
Foundation