Serverless-offline: JSON Parse Error for Body Array

Created on 7 Dec 2016  路  5Comments  路  Source: dherault/serverless-offline

Hey Guys,

Ran into a little issue when I tried to POST a JSON payload to serverless-offline that was an array rather than a dictionary as the top level. Outputting the event, the relevant body attribute in serverless-offline outputs:

body: '{"[{"uid":"1418542617","queue_name":"LG-SQS"}]":""}',

However, running serverless on API Gateway with the same request yields:

body: '[{"uid":"1418542617","queue_name":"LG-SQS"}]

As you can see, serverless-offline is trying to parse the json as a dict rather than an array.

bug help wanted

Most helpful comment

@dherault just tried with 3.8.3 and it's parsing the json-array payload correctly. Thanks everyone.

All 5 comments

Thanks @imackinn, I was able to reproduce and will work on it (but please anyone PR if they need it fixed sooner)

I'm not working on this right now sorry u_u. Relates to #173

Hi @dherault, I tested it locally and couldn't reproduce the issue. I created a POST handler and sent it this payload as described by @imackinn

[{"uid":"1418542617", "queue_name":"LG-SQS"}]

In serverless-offline I got body: [ { uid: '1418542617', queue_name: 'LG-SQS' } ] correctly parsed.
I'm running the latest version from master.

Did I understand correctly the problem? or could it have been solved in the latest version?

Cheers.

Thanks @ansraliant for your input.
@imackinn do you still encourter the issue? If yes can you tell us more about your setup?

@dherault just tried with 3.8.3 and it's parsing the json-array payload correctly. Thanks everyone.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dnalborczyk picture dnalborczyk  路  3Comments

ghost picture ghost  路  4Comments

Ali-Dalal picture Ali-Dalal  路  4Comments

FranzSkuffka picture FranzSkuffka  路  3Comments

jormaechea picture jormaechea  路  4Comments