Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json 将自定义名称添加到AllowedValue_Json - Fatal编程技术网

Json 将自定义名称添加到AllowedValue

Json 将自定义名称添加到AllowedValue,json,Json,我有JSON模板文件的以下部分 "environment": { "type": "string", "defaultValue": "Test", "allowedValues": [ "Development", "Test", "User Acceptance Testing", "Load Testing", "Stage", "Production" ] 运行时,将按原样显示此环境列表。但是,我希望能够使用您在这里看到的

我有JSON模板文件的以下部分

"environment": {
  "type": "string",
  "defaultValue": "Test",
  "allowedValues": [
    "Development",
    "Test",
    "User Acceptance Testing",
    "Load Testing",
    "Stage",
    "Production"
  ]
运行时,将按原样显示此环境列表。但是,我希望能够使用您在这里看到的仅显示名称,然后选择一个后,应用另一个值,例如Production=PDN,Load Testing=LT


如何将其写入上述代码?

是否使用默认json模式?因为其中没有诸如
defaultValue
allowedValues
之类的关键字

有关详细信息,请参阅

首先,出于您的目的,您应该使用
enum
而不是
allowedValues
default
而不是
defaultValue
,因此您的架构如下所示:

"environment": {
  "type": "string",
  "default": "Test",
  "enum": [
    "Development",
    "Test",
    "User Acceptance Testing",
    "Load Testing",
    "Stage",
    "Production"
  ]
}
对于您的问题,我想这种处理应该在您的JavaScript(或者您正在使用什么)代码中实现,它使用您的json模式

因此,您应该将
环境的“短”版本(如PND、LT等)存储到模式中,并将完整值存储到代码中。可能是您计划的一部分

模式的最终版本:

"environment": {
  "type": "string",
  "default": "TST",
  "enum": [
    "DMT",
    "TST",
    "UAT",
    "LT",
    "STG",
    "PND"
  ]
}

哪个代码??Javascript还是什么?你试过什么?请提供更多信息!别这么认为,Azure使用普通的JSON,我可以在visual studio中编辑它,然后首先验证它。@MarcKean,噢。现在我明白了。请在qiestion详细信息中提供有关您的框架的信息,因为您正在使用Azure及其field scheme并不明显。