0

I trying to format my output from a lambda function into JSON. The lambda function queries my Amazon Aurora RDS instance and returns an array of rows in the following format:

  • [[name,age,town,postcode]]

which gives the an example output:

  • [["James", 23, "Maidenhead","sl72qw"]]

I understand that mapping templates are designed to translate one format to another but I don't understand how I can take the output above and map in to a JSON format using these mapping templates.

I have checked the documentation and it only covers converting one JSON to another.

Hank D
  • 6,271
  • 2
  • 26
  • 35
user3024827
  • 1,228
  • 4
  • 18
  • 36
  • 1
    What language are you using in lambda? Javascript? Python? Java? What are you using to pull the data out of Amazon Aurora? I suspect that you're pulling the data out without using a required parameter that'll give you an associative array instead of a numeric array, but you haven't supplied enough information to tell. – Doug Feb 21 '16 at 14:59
  • I am using Python in Lambda. I am using the pymysql module to get the data from the database. – user3024827 Feb 21 '16 at 15:55

1 Answers1

0

Without seeing the code you're specifically using, it's difficult to give you a definitely correct answer, but I suspect what you're after is returning the data from python as a dictionary then converting that to JSON.

It looks like this thread contains the relevant details on how to do that.

More specifically, using the DictCursor

cursor = connection.cursor(pymysql.cursors.DictCursor)
Community
  • 1
  • 1
Doug
  • 3,312
  • 1
  • 24
  • 31