title: Reading JSON file from S3 with AWS Lambda
body: <p>First of all, I'm new to AWS so I apologize if the question is very simple or not explained properly.
  I'm trying to read a JSON file stored in a S3 bucket with an AWS lambda function.
  My main problem is that I am completely unable to extract the information from it.
  This is my code:</p>
  
  <p>**</p>
  
  <pre><code>import json
  import boto3
  def lambda_handler(event, context):
      BUCKET = 'BUCKET'
      KEY = 'KEY.json'
      client = boto3.client('s3')
      result = client.get_object(Bucket=BUCKET, Key=KEY)
      # Read the object 
      text = result['Body'].read()#.decode('utf-8')
      #convert to string
      text_str = str(text)
      text_str = text_str.replace('\r\n', '')
  
      print(text_str)
  </code></pre>
  
  <p>**</p>
  
  <p>If i use decode('utf-8'), I get: "errorMessage": "'utf-8' codec can't decode byte 0xba in position 976: invalid start byte".
  If i don't, i get the JSON file but like this:</p>
  
  <p>'{\r\n  "id": 0,\r\n  "uid": "uid",\r\n  "name": "User",\r\n  "last": "Candidate"}'</p>
  
  <p>I am stuck here, because the .replace doesn't work and I don't know how to use what i get and access to it as in a standard JSON.</p>
  
  <p>Thank you in advance.   </p>
  
  <hr>
  
  <p>Update: looks like the main problem is that I have ASCii characters like 'á' in the JSON file. Now, I get something like this (I just show a part of the json):</p>
  
  <p>'{"id": 0,"uid": "uid","name": "User","last": "Candidate"}'</p>
  
  <p>I've tried ast.literal_eval to get rid of the '' and access the dictionary, and also json.dumps to try to avoid the problem with the ASCii characters, but nothing has worked.</p>