传递JSON数组aws api

时间:2017-01-22 20:09:29

标签: json amazon-web-services aws-lambda

我有这个模型Jsonchéma:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "ArrayINPUT",
  "type": "object",
  "properties": {
    "QueryID": { "type": "integer" },
    "nR": { "type": "integer" },
    "Inarray": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "ids": { "type": "integer" },
          "contents": { "type": "string" }
        }
      }
    }
  }
}

我需要将带有数组ID和内容的这个Inarray数组传递给api aws

我不知道这个inArray的格式是什么?:“?:

Inarray [0,"sdasd",1,"sdfsdfsdfdgfd",2,"asdjkfbfgbsdhbfhsdfbg"........]

这样的东西?或者我必须创建一些特殊的数组并放入这个包含这两个数组的数组:?

我得到的输出:是空的Inarray

{
  "nR": "5",
  "Inarray": [],
  "QueryID": ""
}

我的JSOn身体映射模板:

#set($inputRoot = $input.path('$'))
{
  "QueryID" : "$input.params('QueryID')",
  "nR" : "$input.params('nR')",
  "Inarray" : [
##TODO: Update this foreach loop to reference array from input json
#foreach($elem in $input.params('Inarray'))
 {
    "ids" : "$elem.ids",
    "contents" : "$elem.contents"
  } 
#if($foreach.hasNext),#end
#end
]
}

1 个答案:

答案 0 :(得分:0)

您忽略了$ inputRoot变量(这是一个速度模板)。

我认为你会更喜欢这样的事情:

.* matches any character (except for line terminators)
  * Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)
\n matches a line-feed (newline) character (ASCII 10)
.* matches any character (except for line terminators)
  * Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)
\n matches a line-feed (newline) character (ASCII 10)
LINE 5 matches the characters LINE 5 literally (case sensitive)