skip to Main Content

Environment = AWS cloud, DynamoDB, AWS Cloud9, Python, JSON.

I am trying to right these items into a DynamoDB table with the command aws dynamodb batch-write-item –request-items file://Sensors.json in my Cloud9 CLI.

When I do run the command it returns this error Error parsing parameter ‘–request-items’: Invalid JSON: No JSON object could be decoded

The .json file is located in the same AWS Cloud9 directory and where I am running the command and where I am trying to create dynamodb tables. I believe this has to be some kind of formatting issue, but I just cannot see where.

Here is full JSON code

{
    "Sensors": [
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Bears.png"},
                    "SenorDescription": {"S": "Chicago Bears"},
                    "SampleRate": {"N": "2020" },
                    "Sensor": {"S": "001"},
                    "Locations": {"S":"Chicago IL"}
                }
            }    
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Bengals.png"},
                    "SenorDescription": {"S": "Cincinnati Bengals"},
                    "SampleRate": {"N": "2021" },
                    "Sensor": {"S": "002"},
                    "Locations": {"S":"Cincinnati OH"}
                }
            }    
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Bills.png"},
                    "SenorDescription": {"S": "Buffalo Bills"},
                    "SampleRate": {"N": "2022" },
                    "Sensor": {"S": "003"},
                    "Locations": {"S":"Orchard Park NY"}
                }
            }
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Broncos.png"},
                    "SenorDescription": {"S": "Denver Broncos"},
                    "SampleRate": {"N": "2023" },
                    "Sensor": {"S": "004"},
                    "Locations": {"S":"Denver CO"}
                }
            }
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Browns.png"},
                    "SenorDescription": {"S": "Cleveland Browns"},
                    "SampleRate": {"N": "2024" },
                    "Sensor": {"S": "005"},
                    "Locations": {"S":"Cleveland OH"}
                }
            }
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Cardinals.png"},
                    "SenorDescription": {"S": "Arizona Cardinals"},
                    "SampleRate": {"N": "2025" },
                    "Sensor": {"S": "006"},
                    "Locations": {"S":"Glendale AR"}
                }
            }
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Chiefs.png"},
                    "SenorDescription": {"S": "Kansas City Chiefs"},
                    "SampleRate": {"N": "2026" },
                    "Sensor": {"S": "007"},
                    "Locations": {"S":"Kansas City MO"}
                }
            }
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Colts.png"},
                    "SenorDescription": {"S": "Indianapolis Colts"},
                    "SampleRate": {"N": "2027" },
                    "Sensor": {"S": "008"},
                    "Locations": {"S":"Indianapolis IN"}
                }
            }
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Cowboys.png"},
                    "SenorDescription": {"S": "Dallas Cowboys"},
                    "SampleRate": {"N": "2028" },
                    "Sensor": {"S": "009"},
                    "Locations": {"S":"Dallas TX"}
                }
            }
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Falcons.png"},
                    "SenorDescription": {"S": "Atlanta Falcons"},
                    "SampleRate": {"N": "2029" },
                    "Sensor": {"S": "010"},
                    "Locations": {"S":"Atlanta GA"}
                }
            }
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Jaguars.png"},
                    "SenorDescription": {"S": "Jacksonville Jaguars"},
                    "SampleRate": {"N": "2030" },
                    "Sensor": {"S": "011"},
                    "Locations": {"S":"Jacksonville FL"}
                }
            }
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Lions.png"},
                    "SenorDescription": {"S": "Detroit Lions"},
                    "SampleRate": {"N": "2031" },
                    "Sensor": {"S": "012"},
                    "Locations": {"S":"Detroit MI"}
                }
            }
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Packers.png"},
                    "SenorDescription": {"S": "Greeb Bay Packers"},
                    "SampleRate": {"N": "2032" },
                    "Sensor": {"S": "013"},
                    "Locations": {"S":"Green Bay WI"}
                }
            }
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Panthers.png"},
                    "SenorDescription": {"S": "Carolina Panthers"},
                    "SampleRate": {"N": "2033" },
                    "Sensor": {"S": "014"},
                    "Locations": {"S":"Charlotte NC"}
                }
            }
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Raiders.png"},
                    "SenorDescription": {"S": "Las Vegas Raiders"},
                    "SampleRate": {"N": "2034" },
                    "Sensor": {"S": "015"},
                    "Locations": {"S":"Las Vegas NV"}
                }
            }
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Rams.png"},
                    "SenorDescription": {"S": "Los Angeles Rams"},
                    "SampleRate": {"N": "2035" },
                    "Sensor": {"S": "016"},
                    "Locations": {"S":"Los Angeles CA"}
                }
            }
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Ravens.png"},
                    "SenorDescription": {"S": "Baltimore Ravens"},
                    "SampleRate": {"N": "2036" },
                    "Sensor": {"S": "017"},
                    "Locations": {"S":"Baltimore MD"}
                }
            }
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Saints.png"},
                    "SenorDescription": {"S": "New Orleans Saints"},
                    "SampleRate": {"N": "2037" },
                    "Sensor": {"S": "018"},
                    "Locations": {"S":"New Orleans LA"}
                }
            }
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Texans.png"},
                    "SenorDescription": {"S": "Houston Texans"},
                    "SampleRate": {"N": "2038" },
                    "Sensor": {"S": "019"},
                    "Locations": {"S":"Houston TX"}
                }
            }
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Vikings.png"},
                    "SenorDescription": {"S": "Minnesota Vikings"},
                    "SampleRate": {"N": "2039" },
                    "Sensor": {"S": "020"},
                    "Locations": {"S":"Minnesota MN"}
                }
            }
        },
    ]
}

Full Error below

Error parsing parameter '--request-items': Invalid JSON: No JSON object could be decoded
JSON received: {
    "Sensors": [
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Bears.png"},
                    "SenorDescription": {"S": "Chicago Bears"},
                    "SampleRate": {"N": "2020" },
                    "Sensor": {"S": "001"},
                    "Locations": {"S":"Chicago IL"}
                }
            }    
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Bengals.png"},
                    "SenorDescription": {"S": "Cincinnati Bengals"},
                    "SampleRate": {"N": "2021" },
                    "Sensor": {"S": "002"},
                    "Locations": {"S":"Cincinnati OH"}
                }
            }    
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Bills.png"},
                    "SenorDescription": {"S": "Buffalo Bills"},
                    "SampleRate": {"N": "2022" },
                    "Sensor": {"S": "003"},
                    "Locations": {"S":"Orchard Park NY"}
                }
            }
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Broncos.png"},
                    "SenorDescription": {"S": "Denver Broncos"},
                    "SampleRate": {"N": "2023" },
                    "Sensor": {"S": "004"},
                    "Locations": {"S":"Denver CO"}
                }
            }
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Browns.png"},
                    "SenorDescription": {"S": "Cleveland Browns"},
                    "SampleRate": {"N": "2024" },
                    "Sensor": {"S": "005"},
                    "Locations": {"S":"Cleveland OH"}
                }
            }
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Cardinals.png"},
                    "SenorDescription": {"S": "Arizona Cardinals"},
                    "SampleRate": {"N": "2025" },
                    "Sensor": {"S": "006"},
                    "Locations": {"S":"Glendale AR"}
                }
            }
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Chiefs.png"},
                    "SenorDescription": {"S": "Kansas City Chiefs"},
                    "SampleRate": {"N": "2026" },
                    "Sensor": {"S": "007"},
                    "Locations": {"S":"Kansas City MO"}
                }
            }
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Colts.png"},
                    "SenorDescription": {"S": "Indianapolis Colts"},
                    "SampleRate": {"N": "2027" },
                    "Sensor": {"S": "008"},
                    "Locations": {"S":"Indianapolis IN"}
                }
            }
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Cowboys.png"},
                    "SenorDescription": {"S": "Dallas Cowboys"},
                    "SampleRate": {"N": "2028" },
                    "Sensor": {"S": "009"},
                    "Locations": {"S":"Dallas TX"}
                }
            }
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Falcons.png"},
                    "SenorDescription": {"S": "Atlanta Falcons"},
                    "SampleRate": {"N": "2029" },
                    "Sensor": {"S": "010"},
                    "Locations": {"S":"Atlanta GA"}
                }
            }
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Jaguars.png"},
                    "SenorDescription": {"S": "Jacksonville Jaguars"},
                    "SampleRate": {"N": "2030" },
                    "Sensor": {"S": "011"},
                    "Locations": {"S":"Jacksonville FL"}
                }
            }
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Lions.png"},
                    "SenorDescription": {"S": "Detroit Lions"},
                    "SampleRate": {"N": "2031" },
                    "Sensor": {"S": "012"},
                    "Locations": {"S":"Detroit MI"}
                }
            }
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Packers.png"},
                    "SenorDescription": {"S": "Greeb Bay Packers"},
                    "SampleRate": {"N": "2032" },
                    "Sensor": {"S": "013"},
                    "Locations": {"S":"Green Bay WI"}
                }
            }
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Panthers.png"},
                    "SenorDescription": {"S": "Carolina Panthers"},
                    "SampleRate": {"N": "2033" },
                    "Sensor": {"S": "014"},
                    "Locations": {"S":"Charlotte NC"}
                }
            }
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Raiders.png"},
                    "SenorDescription": {"S": "Las Vegas Raiders"},
                    "SampleRate": {"N": "2034" },
                    "Sensor": {"S": "015"},
                    "Locations": {"S":"Las Vegas NV"}
                }
            }
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Rams.png"},
                    "SenorDescription": {"S": "Los Angeles Rams"},
                    "SampleRate": {"N": "2035" },
                    "Sensor": {"S": "016"},
                    "Locations": {"S":"Los Angeles CA"}
                }
            }
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Ravens.png"},
                    "SenorDescription": {"S": "Baltimore Ravens"},
                    "SampleRate": {"N": "2036" },
                    "Sensor": {"S": "017"},
                    "Locations": {"S":"Baltimore MD"}
                }
            }
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Saints.png"},
                    "SenorDescription": {"S": "New Orleans Saints"},
                    "SampleRate": {"N": "2037" },
                    "Sensor": {"S": "018"},
                    "Locations": {"S":"New Orleans LA"}
                }
            }
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Texans.png"},
                    "SenorDescription": {"S": "Houston Texans"},
                    "SampleRate": {"N": "2038" },
                    "Sensor": {"S": "019"},
                    "Locations": {"S":"Houston TX"}
                }
            }
        },
        {
            "PutRequest": {
                "Item": {
                    "ImageFile": {"S": "/Images/Vikings.png"},
                    "SenorDescription": {"S": "Minnesota Vikings"},
                    "SampleRate": {"N": "2039" },
                    "Sensor": {"S": "020"},
                    "Locations": {"S":"Minnesota MN"}
                }
            }
        },
    ]
}

2

Answers


  1. Your JSON looks correct. I would suggest ensuring you’re reaching the file correctly and it’s saved in the correct format.

    Login or Signup to reply.
  2. The JSON is incorrect, there is a comma after the last item in the array, just before the closing square bracket.

           },
        ] 
    }
    

    The same comma can bee seen in the aws cli command output, delete it from the source file and try again.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search