Может ли кто-нибудь помочь мне с шаблоном сопоставления ответов? - PullRequest
0 голосов
/ 27 августа 2018
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "Post": {
      "type": "array",
      "items": [
        {
          "type": "object",
          "properties": {
            "userId": {
              "type": "string"
            },
            "displayName": {
              "type": "string"
            },
            "dpurl": {
              "type": "string"
            },
            "postId": {
              "type": "string"
            },
            "rawString": {
              "type": "string"
            },
            "richString": {
              "type": "array",
              "items" : {
                  "type": "string"
                }
            },
            "postURL": {
               "type": "string"
            },
            "loopCount": {
              "type": "integer"
            },
            "lapseCount": {
              "type": "integer"
            },
            "postTime": {
              "type": "string"
            },
            "loopStatus": {
              "type": "integer"
                },
                "lapseStatus": {
              "type": "integer"
            }
          }
        }
      ]
    }
  }
}

Выше приведен вход JSON, для которого шаблон сопоставления ответов находится ниже.

Ошибка для массива richString. В чем может быть причина?

#set($inputRoot = $input.path('$'))
#set($richString = $inputRoot.Post)
[

#foreach($elem in $inputRoot.Post)
 {
  "userId" : "$elem.userId",
  "displayName" : "$elem.displayName",
  "dpurl" : "$elem.dpurl",
  "postId" : "$elem.postId",
  "rawString" : "$elem.rawString",
  "richString" : [
        #foreach($item in $richString.richString)
                    "$item" 
        #if($foreach.hasNext),#end
        #end
          ],
  "loopCount" : "$elem.loopCount",
  "lapseCount" : "$elem.lapseCount",
  "postTime" : "$elem.postTime",
  "loopStatus" : "$elem.loopStatus",
  "lapseStatus" : "$elem.lapseStatus"
    } 
    #if($foreach.hasNext),#end
     #end
]

Полагаю, ошибка в массиве richString. Итак, какой будет правильный шаблон отображения ответов? Я использую веб-сервисы AWS, если это поможет.

...