amazon web services - AWS Gateway API fails to convert DynamoDb JSON in array to regular JSON -


i attempting create service outputs json dynamo db database. however, after implementing body mapping templates in amazon gateway api, service converts pieces of dynamodb json regular json. there no error visible in logs. have attached below body mapping templates, , response body get.

body mapping template:

    #set($inputroot = $input.path('$'))     #foreach($elem in $inputroot.items) {         "accession" : "$elem.accession.s",         "entryname" : "$elem.entryname.s",         "sequence" : "$elem.sequence.s",         "sequencechecksum" : "$elem.sequencechecksum.s",         "taxid" : "$elem.taxid.n",         "features" : "$elem.features.l"     } #if($foreach.hasnext),#end     #end 

response:

 {    "accession" : "p05067",    "entryname" : "a4_human",    "sequence" : "mlpglallllaawtaralevptdgnagllaepqiamfcgrlnmhmnvqngkwdsdpsgtktcidtkegilqycqevypelqitnvveanqpvtiqnwckrgrkqckthphfvipyrclvgefvsdallvpdkckflhqermdvcethlhwhtvaketcsekstnlhdygmllpcgidkfrgvefvccplaeesdnvdsadaeeddsdvwwggadtdyadgsedkvvevaeeeevaeveeeeadddeddedgdeveeeaeepyeeaterttsiatttttttesveevvrevcseqaetgpcramisrwyfdvtegkcapffyggcggnrnnfdteeycmavcgsamsqsllkttqeplardpvklpttaastpdavdkyletpgdenehahfqkakerleakhrermsqvmreweeaerqaknlpkadkkaviqhfqekvesleqeaanerqqlvethmarveamlndrrrlalenyitalqavpprprhvfnmlkkyvraeqkdrqhtlkhfehvrmvdpkkaaqirsqvmthlrviyermnqslsllynvpavaeeiqdevdellqkeqnysddvlanmiseprisygndalmpsltetkttvellpvngefslddlqpwhsfgadsvpantenevepvdarpaadrglttrpgsgltnikteeisevkmdaefrhdsgyevhhqklvffaedvgsnkgaiiglmvggvviatvivitlvmlkkkqytsihhgvvevdaavtpeerhlskmqqngyenptykffeqmqn",    "sequencechecksum" : "a12ee761403740f5",    "taxid" : "9606",    "features" : "[{"m":{"category":{"s":"molecule_processing"},"description":{"s":" "},"type":"category":{"s":"molecule_processing"},"description":{"s":"amyloid beta a4 protein"},"type":{"s":"chain"},"end":{"s":"770"},"begin":{"s":"18"}}},{"m":{"ftid":{"s":"pro_0000000089"},"category":{"s":"molecule_processing"},"description":{"s":"soluble app-alpha"},"type":{"s":"chain"},"end":{"s":"687"},"begin":{"s":"18"}}},{"m":{"ftid":{"s":"pro_0000000090"},"category":{"s":"molecule_processing"},"description":{"s":"soluble app-beta"},"type":{"s":"chain"},"end":{"s":"671"},"begin":{"s":"18"}}},{"m":{"ftid":{"s":"pro_0000381966"},"category":{"s":"molecule_processing"},"description":{"s":"n-app"},"type":{"s":"chain"},"end":{"s":"286"},"begin":{"s":"18"}}},{"m":{"ftid":{"s":"pro_0000000091"},"category":{"s":"molecule_processing"},"description":{"s":"c99"},"type":{"s":"chain"},"end":{"s":"770"},"begin":{"s":"672"}}},{"m":{"ftid":{"s":"pro_0000000092"},"category":{"s":"molecule_processing"},"description":{"s":"beta-amyloid protein 42"},"type":{"s":"chain"},"end":{"s":"713"},"begin":{"s":"672"}}}]"         }          response headers {"content-type":"application/json"} logs execution log request test-request mon aug 08 15:26:05 utc 2016 : starting execution request: test-invoke-request mon aug 08 15:26:05 utc 2016 : http method: get, resource path: /proteins/{accession} mon aug 08 15:26:05 utc 2016 : method request path: {accession=p05067} mon aug 08 15:26:05 utc 2016 : method request query string: {} mon aug 08 15:26:05 utc 2016 : method request headers: {} mon aug 08 15:26:05 utc 2016 : method request body before transformations: null mon aug 08 15:26:05 utc 2016 : endpoint request uri: https://dynamodb.us-west-2.amazonaws.com/?action=query mon aug 08 15:26:05 utc 2016 : endpoint request headers: {authorization=****************************************************************************************************************************************************************************************************************************************************************************************b0b302, x-amz-date=20160808t152605z, x-amzn-apigateway-api-id=9x56sueb85, accept=application/json, user-agent=amazonapigateway_9x56sueb85, x-amz-security-token=agogb3jpz2luejv//////////weacxvzlxdlc3qtmikaalxlb1cz9vo5kf2llpuptpp1ftihmbbbzhomqw30/jcc5q3rv+bm9k0ltqfjxrdrpzw5dehg1dmla1k8ljha+og4rgyfdpj/9wdc4u1wknzdy/lzfuamey0yotnc+rniwymq+zivhy94sv/zkj+dxsgkdzbz5a6jbfj4efvfumlc3kha4tjkwp6pcxpyhjqfqq+uui/q0cohnqv0eubd6hnuboebzes2tiqdtha8f4k+avx7o1f3lcpijfvdpn4inoxz7zmhdgpleuxuroz7tazjoxfthxprg2gacitnj7gqascsxraql/4gujc6yydgievee6v5zn5prirnhpz0lmcq8qii8f//////////araaggw5mtuzmzi4mzc1ndaidd4axveobprjuq28zirfaj5mjun8gxufxuqc1azd08plgpatrz11k1xgax/atvptuj//pcy+4fs90pqdzsqmsms8ksd0x46m7gfhnnzuqypcdy3lyyn [truncated] mon aug 08 15:26:05 utc 2016 : endpoint request body after transformations: {     "tablename": "protein_db",     "indexname": "accession-index",     "keyconditionexpression": "accession = :v1",         "expressionattributevalues": {             ":v1":  {                 "s": "p05067"             }         } } mon aug 08 15:26:05 utc 2016 : endpoint response body before transformations: {"count":1,"items":[{"accession":{"s":"p05067"},"features":{"l":[{"m":{"category":{"s":"molecule_processing"},"description":{"s":" "},"type":{"s":"signal"},"evidences":{"l":[{"m":{"source":{"m":{"id":{"s":"12665801"},"alternativeurl":{"s":"http://europepmc.org/abstract/med/12665801"},"name":{"s":"pubmed"},"url":{"s":"http://www.ncbi.nlm.nih.gov/pubmed/12665801"}}},"code":{"s":"eco:0000269"}}},{"m":{"source":{"m":{"id":{"s":"2900137"},"alternativeurl":{"s":"http://europepmc.org/abstract/med/2900137"},"name":{"s":"pubmed"},"url":{"s":"http://www.ncbi.nlm.nih.gov/pubmed/2900137"}}},"code":{"s":"eco:0000269"}}},{"m":{"source":{"m":{"id":{"s":"3597385"},"alternativeurl":{"s":"http://europepmc.org/abstract/med/3597385"},"name":{"s":"pubmed"},"url":{"s":"http://www.ncbi.nlm.nih.gov/pubmed/3597385"}}},"code":{"s":"eco:0000269"}}}]},"end":{"s":"17"},"begin":{"s":"1"}}},{"m":{"ftid":{"s":"pro_0000000088"},"category":{"s":"molecule_processing"},"description":{"s":"amyloid b [truncated] mon aug 08 15:26:05 utc 2016 : endpoint response headers: {x-amzn-requestid=j0j7k1rfdogek20v70t0hkj14jvv4kqnso5aemvjf66q9asuaajg, x-amz-crc32=273504943, content-length=75281, date=mon, 08 aug 2016 15:26:05 gmt, content-type=application/x-amz-json-1.0} mon aug 08 15:26:05 utc 2016 : method response body after transformations:           {             "accession" : "p05067",             "entryname" : "a4_human",             "sequence" : "mlpglallllaawtaralevptdgnagllaepqiamfcgrlnmhmnvqngkwdsdpsgtktcidtkegilqycqevypelqitnvveanqpvtiqnwckrgrkqckthphfvipyrclvgefvsdallvpdkckflhqermdvcethlhwhtvaketcsekstnlhdygmllpcgidkfrgvefvccplaeesdnvdsadaeeddsdvwwggadtdyadgsedkvvevaeeeevaeveeeeadddeddedgdeveeeaeepyeeaterttsiatttttttesveevvrevcseqaetgpcramisrwyfdvtegkcapffyggcggnrnnfdteeycmavcgsamsqsllkttqeplardpvklpttaastpdavdkyletpgdenehahfqkakerleakhrermsqvmreweeaerqaknlpkadkkaviqhfqekvesleqeaanerqqlvethmarveamlndrrrlalenyitalqavpprprhvfnmlkkyvraeqkdrqhtlkhfehvrmvdpkkaaqirsqvmthlrviyermnqslsllynvpavaeeiqdevdellqkeqnysddvlanmiseprisygndalmpsltetkttvellpvngefslddlqpwhsfgadsvpantenevepvdarpaadrglttrpgsgltnikteeisevkmdaefrhdsgyevhhqklvffaedvgsnkgaiiglmvggvviatvivitlvmlkkkqytsihhgvvevdaavtpeerhlskmqqngyenptykffeqmqn",             "sequencechecksum" : "a12ee761403740f5",             "taxid" : "9606",              [truncated] mon aug 08 15:26:05 utc 2016 : method response headers: {content-type=application/json} mon aug 08 15:26:05 utc 2016 : completed execution mon aug 08 15:26:05 utc 2016 : method completed status: 200 

i've attempted format featuers field little sucess.here attempt:

#set($inputroot = $input.path('$'))          #foreach($elem in $inputroot.items) {             "accession" : "$elem.accession.s",             "entryname" : "$elem.entryname.s",             "sequence" : "$elem.sequence.s",             "sequencechecksum" : "$elem.sequencechecksum.s",             "taxid" : "$elem.taxid.n",             "features" : "$elem.features.l"         }#if($foreach.hasnext),#end #end  #foreach($elem in $inputroot.items.features)       {         "alternativesequence": "$elem.alternativesequence.s",         "begin": "$elem.begin.s",         "category": "$elem.category.s",         "description": "$elem.description.s",         "end": "$elem.end.s",         "evidences": "$elem.evidences.l",         "ftid": "$elem.ftid.s",         "type": "$elem.type.s"       }#if($foreach.hasnext),#end  #end`` 

is problem 'features' field? think added quotes when aren't necessary.

#set($inputroot = $input.path('$')) #foreach($elem in $inputroot.items) {     "accession" : "$elem.accession.s",     "entryname" : "$elem.entryname.s",     "sequence" : "$elem.sequence.s",     "sequencechecksum" : "$elem.sequencechecksum.s",     "taxid" : "$elem.taxid.n",     "features" : $elem.features.l } #if($foreach.hasnext),#end #end 

Comments