json_to_dictT_json_to_dictJsonToDictJsonToDictjson_to_dict (算子)
名称
json_to_dictT_json_to_dictJsonToDictJsonToDictjson_to_dict — 将 JSON 字符串变换为字典。
签名
void JsonToDict(const HTuple& JsonString, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* DictHandle)
static HDictArray HDict::JsonToDict(const HTuple& JsonString, const HTuple& GenParamName, const HTuple& GenParamValue)
void HDict::JsonToDict(const HString& JsonString, const HString& GenParamName, const HString& GenParamValue)
void HDict::JsonToDict(const char* JsonString, const char* GenParamName, const char* GenParamValue)
void HDict::JsonToDict(const wchar_t* JsonString, const wchar_t* GenParamName, const wchar_t* GenParamValue)
(
Windows only)
描述
json_to_dictjson_to_dictJsonToDictJsonToDictJsonToDictjson_to_dict transforms the string passed in JsonStringJsonStringJsonStringJsonStringjsonStringjson_string,
which must be valid JSON, into a dictionary and returns the handle of
the dictionary in DictHandleDictHandleDictHandleDictHandledictHandledict_handle。
Several optional parameters can be set that control the values of
JSON constants. Those parameters can be set via GenParamNameGenParamNameGenParamNameGenParamNamegenParamNamegen_param_name
and GenParamValueGenParamValueGenParamValueGenParamValuegenParamValuegen_param_value and are described in the documentation of
read_dictread_dictReadDictReadDictReadDictread_dict。
json_to_dictjson_to_dictJsonToDictJsonToDictJsonToDictjson_to_dict can transform several strings at once.
For this, JsonStringJsonStringJsonStringJsonStringjsonStringjson_string must contain a tuple of strings.
The output DictHandleDictHandleDictHandleDictHandledictHandledict_handle will then contain one dictionary
per input string.
执行信息
- 多线程类型:独立(即使使用独占算子也能并行运行)。
- 多线程作用域:全局(可从任何线程调用)。
- 未采用并行化处理。
此算子返回一个句柄。请注意,即使该句柄被用作特定算子的输入参数,这些算子仍可能改变此句柄类型的实例状态。
参数
JsonStringJsonStringJsonStringJsonStringjsonStringjson_string (输入控制) string(-array) → HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)
String in JSON format.
默认值:
['{"key":"value"}']
["{"key":"value"}"]
["{"key":"value"}"]
["{"key":"value"}"]
["{"key":"value"}"]
["{"key":"value"}"]
GenParamNameGenParamNameGenParamNameGenParamNamegenParamNamegen_param_name (输入控制) attribute.name(-array) → HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)
Name of the generic parameter.
默认值:
[]
值列表:
'convert_json_arrays_to'"convert_json_arrays_to""convert_json_arrays_to""convert_json_arrays_to""convert_json_arrays_to""convert_json_arrays_to", 'json_value_false'"json_value_false""json_value_false""json_value_false""json_value_false""json_value_false", 'json_value_null'"json_value_null""json_value_null""json_value_null""json_value_null""json_value_null", 'json_value_true'"json_value_true""json_value_true""json_value_true""json_value_true""json_value_true"
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.
默认值:
[]
建议值:
0, 1, 'HNULL'"HNULL""HNULL""HNULL""HNULL""HNULL", 'true'"true""true""true""true""true", 'false'"false""false""false""false""false", 'dict'"dict""dict""dict""dict""dict", 'tuple'"tuple""tuple""tuple""tuple""tuple", 'tuple_if_possible'"tuple_if_possible""tuple_if_possible""tuple_if_possible""tuple_if_possible""tuple_if_possible"
DictHandleDictHandleDictHandleDictHandledictHandledict_handle (输出控制) dict(-array) → HDict, HTupleSequence[HHandle]HTupleHtuple (handle) (IntPtr) (HHandle) (handle)
Dictionary handle.
示例(HDevelop)
json_to_dict ('{"capacity": "medium", "image_height": 1024, "image_width": 1024}', [], [], DictHandle)
结果
如果参数有效,算子 json_to_dictjson_to_dictJsonToDictJsonToDictJsonToDictjson_to_dict 返回值 2 ( H_MSG_TRUE )。如有必要,则抛出异常。
This is especially the case if JsonStringJsonStringJsonStringJsonStringjsonStringjson_string does not contain
valid JSON.
可能的后继
write_dictwrite_dictWriteDictWriteDictWriteDictwrite_dict,
copy_dictcopy_dictCopyDictCopyDictCopyDictcopy_dict
替代
read_dictread_dictReadDictReadDictReadDictread_dict,
create_dictcreate_dictCreateDictCreateDictCreateDictcreate_dict
另见
read_dictread_dictReadDictReadDictReadDictread_dict,
write_dictwrite_dictWriteDictWriteDictWriteDictwrite_dict,
serialize_handleserialize_handleSerializeHandleSerializeHandleSerializeHandleserialize_handle,
deserialize_handledeserialize_handleDeserializeHandleDeserializeHandleDeserializeHandledeserialize_handle
模块
基础