创建 UI 定义转换函数CreateUiDefinition conversion functions
可以使用这些函数在 JSON 数据类型和编码之间转换值。These functions can be used to convert values between JSON data types and encodings.
boolbool
将参数转换为布尔值。Converts the parameter to a boolean. 此函数支持数字、字符串和布尔类型的参数。This function supports parameters of type number, string, and Boolean. 与 JavaScript 中的布尔值相似,0
或 'false'
以外的任何值都返回 true
。Similar to booleans in JavaScript, any value except 0
or 'false'
returns true
.
以下示例返回 true
:The following example returns true
:
"[bool(1)]"
以下示例返回 false
:The following example returns false
:
"[bool(0)]"
以下示例返回 true
:The following example returns true
:
"[bool(true)]"
以下示例返回 true
:The following example returns true
:
"[bool('true')]"
decodeBase64decodeBase64
将参数从 base-64 编码的字符串中解码。Decodes the parameter from a base-64 encoded string. 此函数仅支持字符串类型的参数。This function supports parameters only of type string.
以下示例返回 "Contoso"
:The following example returns "Contoso"
:
"[decodeBase64('Q29udG9zbw==')]"
decodeUriComponentdecodeUriComponent
将参数从 URL 编码的字符串中解码。Decodes the parameter from a URL encoded string. 此函数仅支持字符串类型的参数。This function supports parameters only of type string.
以下示例返回 "https://portal.azure.cn/"
:The following example returns "https://portal.azure.cn/"
:
"[decodeUriComponent('https%3A%2F%2Fportal.azure.com%2F')]"
encodeBase64encodeBase64
将参数编码为 base-64 编码的字符串。Encodes the parameter to a base-64 encoded string. 此函数仅支持字符串类型的参数。This function supports parameters only of type string.
以下示例返回 "Q29udG9zbw=="
:The following example returns "Q29udG9zbw=="
:
"[encodeBase64('Contoso')]"
encodeUriComponentencodeUriComponent
将参数编码为 URL 编码的字符串。Encodes the parameter to a URL encoded string. 此函数仅支持字符串类型的参数。This function supports parameters only of type string.
以下示例返回 "https%3A%2F%2Fportal.azure.com%2F"
:The following example returns "https%3A%2F%2Fportal.azure.com%2F"
:
"[encodeUriComponent('https://portal.azure.cn/')]"
floatfloat
将参数转换为浮点。Converts the parameter to a floating-point. 此函数支持数字和字符串类型的参数。This function supports parameters of type number and string.
以下示例返回 1.0
:The following example returns 1.0
:
"[float('1.0')]"
以下示例返回 2.9
:The following example returns 2.9
:
"[float(2.9)]"
intint
将参数转换为整数。Converts the parameter to an integer. 此函数支持数字和字符串类型的参数。This function supports parameters of type number and string.
以下示例返回 1
:The following example returns 1
:
"[int('1')]"
以下示例返回 2
:The following example returns 2
:
"[int(2.9)]"
parseparse
将参数转换为本机类型。Converts the parameter to a native type. 换而言之,此函数是 string()
函数的反函数。In other words, this function is the inverse of string()
. 此函数仅支持字符串类型的参数。This function supports parameters only of type string.
以下示例返回 1
:The following example returns 1
:
"[parse('1')]"
以下示例返回 true
:The following example returns true
:
"[parse('true')]"
以下示例返回 [1,2,3]
:The following example returns [1,2,3]
:
"[parse('[1,2,3]')]"
以下示例返回 {"type":"webapp"}
:The following example returns {"type":"webapp"}
:
"[parse('{\"type\":\"webapp\"}')]"
stringstring
将参数转换为字符串。Converts the parameter to a string. 此函数支持所有 JSON 数据类型的参数。This function supports parameters of all JSON data types.
以下示例返回 "1"
:The following example returns "1"
:
"[string(1)]"
以下示例返回 "2.9"
:The following example returns "2.9"
:
"[string(2.9)]"
以下示例返回 "[1,2,3]"
:The following example returns "[1,2,3]"
:
"[string([1,2,3])]"
以下示例返回 "{"type":"webapp"}"
:The following example returns "{"type":"webapp"}"
:
"[string({\"type\":\"webapp\"})]"
后续步骤Next steps
- 有关 Azure 资源管理器的简介,请参阅 Azure 资源管理器概述。For an introduction to Azure Resource Manager, see Azure Resource Manager overview.