title: How to write JSON data to Dynamodb by ignoring empty elements in boto3
body: <p>I would like to write the following data group to Dynamodb.<br>
  There are  about 100 data. Since images are not necessarily required, there is a mixture with and without the image_url element.<br>
  <br></p>
  <p>(questionsList.json)</p>
  <pre><code>{
    &quot;q_id&quot; : &quot;001&quot;,
    &quot;q_body&quot; : &quot;Where is the capital of the United States?&quot;,
    &quot;q_answer&quot; : &quot;Washington, D.C.&quot;,
    &quot;image_url&quot; : &quot;/Washington.jpg&quot;,
    &quot;keywords&quot; : [
      &quot;UnitedStates&quot;,
      &quot;Washington&quot;
    ]
  },
  {
    &quot;q_id&quot; : &quot;002&quot;,
    &quot;q_body&quot; : &quot;Where is the capital city of the UK?&quot;,
    &quot;q_answer&quot; : &quot;London&quot;,
    &quot;image_url&quot; : &quot;&quot;,
    &quot;keywords&quot; : [
      &quot;UK&quot;,
      &quot;London&quot;
    ]
  },
  </code></pre>
  <p>Since it is the writing test phase, Dynamodb to write to is prepared in localhost:8000 using the serverless-dynamodb-local plugin of the serverless framework, not the production environment.<br>
  In order to write the above JSON data to this Dynamodb, I wrote the following code in Boto 3 (AWS SDK for Python).<br></p>
  <pre><code>from __future__ import print_function
  import boto3
  import codecs
  import json
  
  dynamodb = boto3.resource('dynamodb', region_name='us-east-1', endpoint_url=&quot;http://localhost:8000&quot;)
  
  table = dynamodb.Table('questionListTable')
  
  with open(&quot;questionList.json&quot;, &quot;r&quot;, encoding='utf-8') as json_file:
      items = json.load(json_file)
      for item in items:
          q_id = item['q_id']
          q_body = item['q_body']
          q_answer = item['q_answer']
          image_url = item['image_url']
          keywords = item['keywords']
  
          print(&quot;Adding detail:&quot;, q_id, q_body)
  
          table.put_item(
              Item={
                  'q_id': q_id,
                  'q_body': q_body,
                  'q_answer': q_answer,
                  'image_url': image_url,
                  'keywords': keywords,
              }
          )
  </code></pre>
  <p>When this code is executed, the following error occurs in the null character part.<br></p>
  <blockquote>
  <p>botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the PutItem operation: One or more parameter values were invalid: An AttributeValue may not contain an empty string</p>
  </blockquote>
  <p>Apparently it seems to be caused by JSON 's null character.<br>
  If you exclude the image_url containing the null character from the target of writing as below, the writing is completed without any problem.<br></p>
  <pre><code>from __future__ import print_function
  import boto3
  import codecs
  import json
  
  dynamodb = boto3.resource('dynamodb', region_name='us-east-1', endpoint_url=&quot;http://localhost:8000&quot;)
  
  table = dynamodb.Table('questionListTable')
  
  with open(&quot;questionList.json&quot;, &quot;r&quot;, encoding='utf-8') as json_file:
      items = json.load(json_file)
      for item in items:
          q_id = item['q_id']
          q_body = item['q_body']
          q_answer = item['q_answer']
          #image_url = item['image_url']
          keywords = item['keywords']
  
          print(&quot;Adding detail:&quot;, q_id, q_body)
  
          table.put_item(
              Item={
                  'q_id': q_id,
                  'q_body': q_body,
                  'q_answer': q_answer,
                  #'image_url': image_url,
                  'keywords': keywords,
              }
          )
  </code></pre>
  <p>Since DynamoDB is NoSQL, there may be other methods that make good use of the characteristics, but how to correct the code to write the above data ignoring empty characters? I would like to say &quot;if image_url exists, write it if it does not, ignore it.&quot;<br>
  <br>
  Thank you.</p>