json_to_dictT_json_to_dictJsonToDictJsonToDictjson_to_dict (算子名称)
名称
json_to_dictT_json_to_dictJsonToDictJsonToDictjson_to_dict — Transform a JSON string into a dictionary.
参数签名
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.
运行信息
- Multithreading type: independent (runs in parallel even with exclusive operators).
- 多线程作用域:全局(可以从任何线程调用)。
- 未经并行化处理。
This operator returns a handle. Note that the state of an instance of this handle type may be changed by specific operators even though the handle is used as an input parameter by those operators.
参数表
JsonStringJsonStringJsonStringJsonStringjsonStringjson_string (input_control) string(-array) → HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)
String in JSON format.
Default:
['{"key":"value"}']
["{"key":"value"}"]
["{"key":"value"}"]
["{"key":"value"}"]
["{"key":"value"}"]
["{"key":"value"}"]
GenParamNameGenParamNameGenParamNameGenParamNamegenParamNamegen_param_name (input_control) attribute.name(-array) → HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)
Name of the generic parameter.
Default:
[]
List of values:
'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 (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:
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 (output_control) 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 returns
the value 2 (
H_MSG_TRUE)
. If necessary an exception is raised.
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
模块
Foundation