dict_to_jsonT_dict_to_jsonDictToJsonDictToJsondict_to_json (算子)
名称
dict_to_jsonT_dict_to_jsonDictToJsonDictToJsondict_to_json — 将字典转换为JSON(JavaScript Object Notation)字符串。
签名
描述
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:
-
'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",
-
'compact_json'"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""use_json_arrays".
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.
执行信息
- 多线程类型:独立(即使使用独占算子也能并行运行)。
- 多线程作用域:全局(可从任何线程调用)。
- 未采用并行化处理。
参数
DictHandleDictHandleDictHandleDictHandledictHandledict_handle (输入控制) dict(-array) → HDict, HTupleMaybeSequence[HHandle]HTupleHtuple (handle) (IntPtr) (HHandle) (handle)
Dictionary handle.
GenParamNameGenParamNameGenParamNameGenParamNamegenParamNamegen_param_name (输入控制) attribute.name(-array) → HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)
Name of the generic parameter.
默认值:
[]
值列表:
'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 (输入控制) 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.
默认值:
[]
建议值:
'true'"true""true""true""true""true", 'false'"false""false""false""false""false"
JsonStringJsonStringJsonStringJsonStringjsonStringjson_string (输出控制) string(-array) → HTupleSequence[str]HTupleHtuple (string) (string) (HString) (char*)
String in JSON format.
示例(HDevelop)
dict_to_json (dict{foo: 'bar', bar: [0:2]}, [], [], JSONString)
结果
如果参数有效,算子 dict_to_jsondict_to_jsonDictToJsonDictToJsonDictToJsondict_to_json 返回值 2 ( H_MSG_TRUE )。如有必要,则抛出异常。
可能的前趋
create_dictcreate_dictCreateDictCreateDictCreateDictcreate_dict,
read_dictread_dictReadDictReadDictReadDictread_dict,
json_to_dictjson_to_dictJsonToDictJsonToDictJsonToDictjson_to_dict
可能的后继
json_to_dictjson_to_dictJsonToDictJsonToDictJsonToDictjson_to_dict
替代
read_dictread_dictReadDictReadDictReadDictread_dict,
create_dictcreate_dictCreateDictCreateDictCreateDictcreate_dict
另见
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
模块
基础