Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.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模式填充动态值_Json_Jsonschema - Fatal编程技术网

为Json模式填充动态值

为Json模式填充动态值,json,jsonschema,Json,Jsonschema,我是json模式的新手,我很难找到解决问题的方法。 我需要使用下面所示的模式填充服务器发送到json编辑器的数据 注意:这只是模式的一个片段。 我有一个json模式,如下所示: { "id": "#ProcessApplicationList", "type": "array", "title":"ProcessApplicationList", "description":"List of process application."

我是json模式的新手,我很难找到解决问题的方法。 我需要使用下面所示的模式填充服务器发送到json编辑器的数据

注意:这只是模式的一个片段。 我有一个json模式,如下所示:




    {
      "id": "#ProcessApplicationList",
      "type": "array",
      "title":"ProcessApplicationList",
      "description":"List of process application.",
      "items": {
        "id": "#ProcessApplication",
        "type": "object",
        "required":[
        "ProcessId",
        "InputParameter"
        ],
        "title":"ProcessApplication",
        "description":"Process application.",
        "properties": {
          "ProcessId":{
            "id":"#ProcessId",
            "type":"string",
            "title":"Identification code of process",
            "description":"e.g. 'process#01'"
          },
          "InputParameter": {
            "id": "#InputParameter",
            "type": "object",
            "additionalProperties": {
              "anyOf": [
                { "type": "string" },
                { "type": "number" },
                { "type": "boolean"}
              ]
            }
          }
        }
      }
    }


这是来自服务器的响应示例



    {
      "Acceptability" : {
        "ProcessList" : [
          {
            "ProcessId" : "process#01",
            "ProcessName" : "sign",
            "ProcessDescription":"sign your plug-in by using signature",
            "ProcessAvailability" : true,
            "ProcessParameterSchema" : {
              "\"$schema\":\"http://json-schema.org/draft-04/schema#\",
              \"sign_type\":{
                \"id\":\"#sign_type\",
                \"type\":\"string\",
                \"title\":\"sign_type\"}
            },
            {
              "ProcessId" : "process#02",
              "ProcessName" : "encryption",
              "ProcessDescription":"encrypt your plug-in by using key",
              "ProcessAvailability" : true,
              "ProcessParameterSchema" : {
                "\"$schema\":\"http://json-schema.org/draft-04/schema#\",
                \"enc_type\": {
                  \"id\":\"#enc_type\",
                  \"type\":\"string\",
                  \"title\":\"enc_type\"
              }
            }
          }
        ]
      }
    }

JSON编辑器的输出应该如下所示: ![IMG]

我需要将“ProcessParameterSchema”的值设置为“InputParameter”。 我需要为“ProcessApplicationList”中的每个元素更新“InputParameter”。 由于“ProcessApplicationList”是一个数组,我不确定如何进行更新。
谢谢大家!

我不确定这是否适用于您的具体情况,但一般的解决方案是使用

使用json hyper schema,您可以定义API可用操作,使用“schema”属性定义可接受的请求格式。答案的模式可以通过“href”链接链接,因此客户机可以友好地处理每个可能的模式


第二个选项是,如果客户端中有所有可能的嵌套模式,则可以通过一个包含“href”集合的“oneOf”属性来表示。在这种情况下,您可以使用这些href进行适当的决策,以验证和绘制UI。一个有趣的变化是将href解析为后端有效URI(这是一种破解前面描述的HAL方法的方法)。

请您再解释一下您的意图。Json模式只允许根据模式验证Json。是否要调整响应以获得架构验证?您是否在响应中对架构进行热更改,然后使用生成的架构进行验证?@jruizaranguren:我更新了我的问题以获取更多信息。是的,我想在每次收到新响应时更新json模式,我需要更新“ProcessApplicationList”中每个元素的“InputParameter”,以便“ProcessParameterSchema”中的模式将显示在json编辑器中。谢谢。您能提前检索所有可能的“ProcessParameterSchema”吗?在创建json模式进行验证之前,我将首先获取“ProcessParameterSchema”的值。我的问题是,我不知道如何将“ProcessParameter”的值设置为“InputParameter”,因为“ProcessApplicationList”中的每个元素的值都可能不同!谢谢你的回复。我确实读过这篇文章,但我对如何做感到困惑。我试图寻找一个类似的案例或参考代码,这样我就可以有一个启动。