2017-01-22 6 views
0

私は、このモデルのJSONスキーマを持っている:パスJSONアレイのAWS API

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

私は、API AWSに

を配列IDと内容でこのInArrayバリ配列を渡す必要があると私はいただきました。このフォーマットを知りませんInArrayバリ?:」:??

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

このような何かまたは私はいくつかの特別な配列を作成し、この配列オブジェクトウィッヒに配置する必要がありますが、この2 ARRが含まれていますays :?

私は何を得るの出力は:空の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 
] 
} 

答えて

0

あなたは$ inputRoot変数を無視している(これはVelocityテンプレートです)。

私はあなたがこのような何か/ wの幸せだと思う:

#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 
] 
} 
関連する問題