title: Error in JSON.parse() (when called from API Gateway)
body: <p>I'm working on AWS lambda + API Gateway, and I need to pass an array of numbers in the url (GET method) for a REST call. It seems a good way is to pass the numbers as string (comma separated) and then use JSON.parse for the conversion to an array of numbers.</p>
  
  <p>Following is the AWS lambda code I'm using;</p>
  
  <pre><code>exports.handler = (event, context, callback) =&gt; {
  
      var arr = JSON.parse('[' + event.numbers + ']');
      console.log("array: " + arr);
  
      // TODO implement
      callback(null, 'Hello from Lambda');
  };
  </code></pre>
  
  <p>I'm testing this function in AWS Lambda using this Input test event;</p>
  
  <pre><code>{
    "numbers": "1,5"
  }
  </code></pre>
  
  <p>And everything works as expected; no errors.</p>
  
  <p>However, when I test it via API Gateway, and passing the numbers as string in the query, I get following error (observed via CloudWatch);</p>
  
  <pre><code>*19:19:02
  START RequestId: eabab882-8cee-11e7-8e2f-79d3086e061f Version: $LATEST
  19:19:02
  2017-08-29T19:19:02.688Z    eabab882-8cee-11e7-8e2f-79d3086e061f    SyntaxError: Unexpected token u in JSON at position 1 at Object.parse (native) at exports.handler (/var/task/index.js:4:20)
  19:19:02
  END RequestId: eabab882-8cee-11e7-8e2f-79d3086e061f
  19:19:02
  REPORT RequestId: eabab882-8cee-11e7-8e2f-79d3086e061f  Duration: 215.25 ms Billed Duration: 300 ms Memory Size: 128 MB Max Memory Used: 18 MB
  19:19:02
  RequestId: eabab882-8cee-11e7-8e2f-79d3086e061f Process exited before completing request*
  </code></pre>
  
  <p>This is the request passed to lambda as shown in the log;</p>
  
  <pre><code>"body-json" : {},
  "params" : {
  "path" : {
      }
      ,"querystring" : {
          "numbers" : "1,6"
              }
      ,"header" : {
      }
      },
  "stage-variables" : {
  },
  </code></pre>
  
  <p>I can't figure out what the problem is, since I'm passing same string in both cases.</p>
  
  <p>I would appreciate any help.</p>
  
  <p>Thanks
  Gus</p>