0

I am having trouble passing valid JSON between two different Java AWS Lambda functions. The first function generates rawJson "String" that is formatted like this:

rawJson: [
  {
    "id": 1,
    "createdOn": 1535177185000,
    "text": "test text"
  }
]

This is passed to a second Lambda function:

request.withFunctionName(FUNCTION_NAME).withPayload(rawJson);
awsLambdaClient.invoke(request);

At the beginning of the second Lambda function, I print the value of the input Object:

inputObject: [{id=1, createdOn=1535177185000, text=test text}]

The quotes have been stripped and this is no longer valid JSON. Any attempt to map this back to my POJOs (or to even have my Lambda function accept a "String" like it should, instead of an "Object") results in a JSON-related exception.

Why is my valid JSON becoming malformed between the two Lambdas?

1 Answer 1

1

This was my fault. Like I mentioned, I had a RequestHandler like this:

RequestHandler<Object, Void>

That wasn't necessary. Lambda is smart enough on its own to serialize and deserialize my objects. Works fine with my code updated to:

RequestHandler<List<MyClass>, Void>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.