"No JSON object could be decoded" when batch writing items to DynamoDB table

Viewed 24

I am trying to write these items into a DynamoDB table. I am using the command: "aws dynamodb batch-write-item --request-items file://items.json" in the Cloud9 CLI

When I run it, I receive the error: "Error parsing parameter '--request-items': Invalid JSON: No JSON object could be decoded"

Up until this point, it was parsing fine, but once I got rid of all the syntax errors the error above occurs. Does anyone know what is causing this? (JSON file code below)

{
    "Sensors":[
        {
            "PutRequest":{
                
                "Item":{
                    "Sensor":{"S": "A"},
                    "SensorDescription":{"S": "light"},
                    "ImageFile":{"S": "/Sensors/images/1.jpg"},
                    "Locations":{"L": ["Canada","USA","China"]}
                }
            }
        },
        {
            "PutRequest":{
                
                "Item":{
                    "Sensor":{"S": "B"},
                    "SampleRate":{"N": "12"},
                    "Locations":{"L": ["USA","China"]}
                }
            }
        },
        {
            "PutRequest":{
                
                "Item":{
                    "Sensor":{"S": "C"},
                    "SensorDescription":{"S": "medium"},
                    "SampleRate":{"N": "13"}
                }
            }
        },
        {
            "PutRequest":{
                
                "Item":{
                    "Sensor":{"S": "D"},
                    "SensorDescription":{"S": "heavy"},
                    "ImageFile":{"S": "/Sensors/images/2.jpg"},
                    "SampleRate":{"N": "14"}
                }
            }
        },
        {
            "PutRequest":{
                
                "Item":{
                    "Sensor":{"S": "E"},
                    "SensorDescription":{"S": "light"},
                    "Locations":{"L": ["USA","Russia","Haiti"]}
                }
            }
        },
        {
            "PutRequest":{
                
                "Item":{
                    "Sensor":{"S": "F"},
                    "SensorDescription":{"S": "light"},
                    "Locations":{"L": ["China","Russia"]}
                }
            }
        },
        {
            "PutRequest":{
                
                "Item":{
                    "Sensor":{"S": "G"},
                    "SensorDescription":{"S": "heavy"},
                    "ImageFile":{"S": "/Sensors/images/3.jpg"},
                    "SampleRate":{"N":"22"}
                }
            }
        },
        {
            "PutRequest":{
                
                "Item":{
                    "Sensor":{"S": "H"},
                    "ImageFile":{"S": ""},
                    "SampleRate":{"N": "45"},
                    "Locations":{"L": ["Jamaica","Taiwan"]}
                }
            }
        },
        {
            "PutRequest":{
                
                "Item":{
                    "Sensor":{"S": "I"},
                    "SensorDescription":{"S": "medium"},
                    "ImageFile":{"S": "/Sensors/images/4.jpg"},
                    "Locations":{"L": ["USA","France","Singapore"]}
                }
            }
        },
        {
            "PutRequest":{
                
                "Item":{
                    "Sensor":{"S": "K"},
                    "SensorDescription":{"S": "heavy"},
                    "Locations":{"L": ["England","Wales"]}
                }
            }
        },
        {
            "PutRequest":{
                
                "Item":{
                    "Sensor":{"S": "L"},
                    "SampleRate":{"N": },
                    "Locations":{"L": ["Canada","Antarctica"]}
                }
            }
        },
        {
            "PutRequest":{
                
                "Item":{
                    "Sensor":{"S": "M"},
                    "SensorDescription":{"S": "light"},
                    "ImageFile":{"S": "/Sensors/images/5.jpg"},
                    "Locations":{"L": ["China","Estonia"]}
                }
            }
        },
        {
            "PutRequest":{
                
                "Item":{
                    "Sensor":{"S": "N"},
                    "SensorDescription":{"S": "medium"},
                    "SampleRate":{"N": "80"}
                }
            }
        },
        {
            "PutRequest":{
                
                "Item":{
                    "Sensor":{"S": "O"},
                    "SensorDescription":{"S": "light"},
                    "SampleRate":{"N": "31"}
                }
            }
        },
        {
            "PutRequest":{
                
                "Item":{
                    "Sensor":{"S": "P"},
                    "SensorDescription":{"S": "medium"},
                    "Locations":{"L": ["Italy","Germany"]},
                    "Region":{"S": "Europe"}
                }
            }
        },
        {
            "PutRequest":{
                
                "Item":{
                    "Sensor":{"S": "Q"},
                    "SampleRate":{"N": "85"},
                    "Locations":{"L": ["Turkey","Bulgaria"]},
                    "Color":{"S": "Red"}
                }
            }
        },
        {
            "PutRequest":{
                
                "Item":{
                    "Sensor":{"S": "R"},
                    "SensorDescription":{"S": "light"},
                    "SampleRate":{"N": "1"},
                    "Rate":{"N": "1500"}
                }
            }
        },
        {
            "PutRequest":{
                
                "Item":{
                    "Sensor":{"S": "S"},
                    "SampleRate":{"N": "21"},
                    "Locations":{"L": ["Ukraine","Georgia"]},
                    "Price":{"N": "36000"}
                }
            }
        },
        {
            "PutRequest":{
                
                "Item":{
                    "Sensor":{"S": "T"},
                    "SensorDescription":{"S": "heavy"},
                    "Locations":{"L": ["Turkey","Phillipines"]},
                    "YearBuilt":{"N": "2003"}
                }
            }
        },
        {
            "PutRequest":{
                
                "Item":{
                    "Sensor":{"S": "J"},
                    "SensorDescription":{"S": "light"},
                    "Locations":{"L": ["Norway","Scotland"]}
                }
            }
        }
    ]
}
1 Answers

After reviewing the posted JSON, I believe the error is b/c the JSON is malformed. Around line 193:

{
    "PutRequest": {
        "Item": {
            "Sensor": {
                "S": "L"
            },
            "SampleRate": {
                "N": // <--- missing value
            },
            "Locations": {
                "L": [
                    "Canada",
                    "Antarctica"
                ]
            }
        }
    }
},

Fix up the JSON and give it a go again.

Related