json_to_dictT_json_to_dictJsonToDictJsonToDictjson_to_dict (算子)

名称

json_to_dictT_json_to_dictJsonToDictJsonToDictjson_to_dict — 将 JSON 字符串变换为字典。

签名

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

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

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)

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

static HDict[] HDict.JsonToDict(HTuple jsonString, HTuple genParamName, HTuple genParamValue)

void HDict.JsonToDict(string jsonString, string genParamName, string genParamValue)

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

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

描述

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

模块

基础