AWS 模型 - JSON string inside string 类型
AWS Model - JSON string inside string type
我想要做的是拥有一个接受 JSON 字符串的基本模型,而不是预先定义我所有的 variables/elements。我的模型将接受一个“选项”元素,我想在其中包含一个 json 字符串。下面是我的模型。
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "GroceryStoreInputModel",
"type": "object",
"properties": {
"options":{"type":"string"}
}
}
在我的 api-gateway 中,这将适用于我只做一个像这样的基本主体:
{"options":"this is my options"}
但是如果我用 json 字符串替换字符串,我会得到一个模型不匹配的错误。
{"options":"{\"name\":\"thaison\",\"mail\":\"test2\"}"}
我也试过 "" escape 但还是不行,有办法吗?
{"options":"{""name"":""thaison"",""mail"":""test2""}"}
您的 options
节点的负载值似乎被解释为 object
而不是 string
。您可以尝试以下设置来解决问题吗?
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "GroceryStoreInputModel",
"type": "object",
"properties": {
"options":{"type":"object"}
}
}
我想要做的是拥有一个接受 JSON 字符串的基本模型,而不是预先定义我所有的 variables/elements。我的模型将接受一个“选项”元素,我想在其中包含一个 json 字符串。下面是我的模型。
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "GroceryStoreInputModel",
"type": "object",
"properties": {
"options":{"type":"string"}
}
}
在我的 api-gateway 中,这将适用于我只做一个像这样的基本主体:
{"options":"this is my options"}
但是如果我用 json 字符串替换字符串,我会得到一个模型不匹配的错误。
{"options":"{\"name\":\"thaison\",\"mail\":\"test2\"}"}
我也试过 "" escape 但还是不行,有办法吗?
{"options":"{""name"":""thaison"",""mail"":""test2""}"}
您的 options
节点的负载值似乎被解释为 object
而不是 string
。您可以尝试以下设置来解决问题吗?
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "GroceryStoreInputModel",
"type": "object",
"properties": {
"options":{"type":"object"}
}
}