json_to_dictT_json_to_dictJsonToDictJsonToDictjson_to_dict (Operator)

Name

json_to_dictT_json_to_dictJsonToDictJsonToDictjson_to_dict — Transform a JSON string into a dictionary.

Signature

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

Description

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.

Execution Information

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.

Parameters

JsonStringJsonStringJsonStringJsonStringjsonStringjson_string (input_control)  string(-array) HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)

String in JSON format.

Default value: ['{"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 value: []

List of values: '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 value: []

Suggested values: 0, 1, 'HNULL'"HNULL""HNULL""HNULL""HNULL""HNULL", 'true'"true""true""true""true""true", 'false'"false""false""false""false""false"

DictHandleDictHandleDictHandleDictHandledictHandledict_handle (output_control)  dict(-array) HDict, HTupleSequence[HHandle]HTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Dictionary handle.

Example (HDevelop)

json_to_dict ('{"capacity": "medium", "image_height": 1024, "image_width": 1024}', [], [], DictHandle)

Result

If the parameters are valid, the operator json_to_dictjson_to_dictJsonToDictJsonToDictJsonToDictjson_to_dict returns the value TRUE. If necessary an exception is raised. This is especially the case if JsonStringJsonStringJsonStringJsonStringjsonStringjson_string does not contain valid JSON.

Possible Successors

write_dictwrite_dictWriteDictWriteDictWriteDictwrite_dict, copy_dictcopy_dictCopyDictCopyDictCopyDictcopy_dict

Alternatives

read_dictread_dictReadDictReadDictReadDictread_dict, create_dictcreate_dictCreateDictCreateDictCreateDictcreate_dict

See also

read_dictread_dictReadDictReadDictReadDictread_dict, write_dictwrite_dictWriteDictWriteDictWriteDictwrite_dict, serialize_handleserialize_handleSerializeHandleSerializeHandleSerializeHandleserialize_handle, deserialize_handledeserialize_handleDeserializeHandleDeserializeHandleDeserializeHandledeserialize_handle

Module

Foundation