传递JSON数组aws api

传递JSON数组aws api,json,amazon-web-services,aws-lambda,Json,Amazon Web Services,Aws Lambda,我有一款Json schéma: { "$schema": "http://json-schema.org/draft-04/schema#", "title": "ArrayINPUT", "type": "object", "properties": { "QueryID": { "type": "integer" }, "nR": { "type": "integer" }, "Inarray": { "type": "array",

我有一款Json sché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

我不知道这张照片的格式是什么

类似这样的东西?或者我必须创建一些特殊的数组并放入这个数组对象,其中包含以下两个数组:

我得到的输出:是空的

{
  "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
]
}

您正在忽略$inputRoot变量(这是一个velocity模板)

我想你会更高兴,比如:

#set($inputRoot) = $input.path('$'))
{
    "QueryID": "$inputRoot.QueryID",
    "nR": $inputRoot.nR,
    "Inarray": [
#foreach($elem in $inputRoot.Inarray)
{
    "ids":$elem.ids,
    "contents": "$elem.contents
}
#if($foreach.hasNext),#end
#end
]
}
#set($inputRoot) = $input.path('$'))
{
    "QueryID": "$inputRoot.QueryID",
    "nR": $inputRoot.nR,
    "Inarray": [
#foreach($elem in $inputRoot.Inarray)
{
    "ids":$elem.ids,
    "contents": "$elem.contents
}
#if($foreach.hasNext),#end
#end
]
}