这是日志:
Logger initialization started Check if directory for storing logs is writeable Directory is writeable Logger initialized
02-05-18 23:45:41 INFO root DHT22logger execution started
02-05-18 23:45:41 INFO Configurations.ConfigHandler ConfigHandler instantiation started
02-05-18 23:45:41 INFO Configurations.ConfigHandler Instantiate ConfigReader 02-05-18 23:45:41 INFO Configurations.ConfigReader ConfigReader instantiation started
02-05-18 23:45:41 INFO Configurations.ConfigReader Loading configurations from config.json
02-05-18 23:45:41 ERROR Configurations.ConfigHandler Instantiation failed
02-05-18 23:45:41 ERROR root Failed to get configurations: Traceback (most recent call last):
File "DHT22logger.py", line 58, in main
configurationHandler = ConfigHandler() File "/home/pi/DHT22-TemperatureLogger/Configurations/ConfigHandler.py", line 17, in __init__
self.configReader = ConfigReader() File "/home/pi/DHT22-TemperatureLogger/Configurations/ConfigReader.py", line 20, in __init__
self.configurations = json.loads(open(configurationFile).read()) File "/usr/lib/python2.7/json/__init__.py", line 339, in loads
return _default_decoder.decode(s) File "/usr/lib/python2.7/json/decoder.py", line 364, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python2.7/json/decoder.py", line 380, in raw_decode
obj, end = self.scan_once(s, idx) ValueError: Expecting , delimiter: line 10 column 11 (char 357)
我在配置文件中找不到任何东西:
{
"mysql":[{
"host":"localhost",
"user":"[username]",
"password":"[password]",
"database":"[database]"
}],
"sensors":
[[{"name":"TEMP"},{"gpio":"4"},{"sensorType":"22"},{"temperatureLowLimit":"0"},{"temperatureHighLimit":"25"},{"temperatureThreshold":"5"},{"humidityLowLimit":"30"},{"humidityHighLimit":"60"},{"humidityThreshold":"10"}],
"mailInfo":[{
"senderaddress":"[MAIL]@gmail.com",
"receiveraddress":"[MAIL]@gmail.com",
"username":"[USER]",
"password":"[PASSWORD]",
"subjectmessage":"Info von RasPi WeatherStation",
"subjectwarning":"Warnung von RasPi WeatherStation"
}],
"sqlBackupDump":[{
"backupDumpEnabled":"y",
"backupDay":"3",
"backupHour":"17",
"backupDumpPath":"/home/pi/DHT22-TemperatureLogger/Backups/"
}],
"weeklyAverages":[{
"weeklyAverageSendingEnabled":"y",
"weekDayForSendingAverages":"3",
"hourOfTheDayForSendingAverages":"16"
}],
"useFahrenheits":"n",
"mailSendingTimeoutInFullHours":"1",
"adafruitPath":"/home/pi/Adafruit_Python_DHT/examples/AdafruitDHT.py"
}
错误指示的部分是mailInfo背后的冒号。
顺便说一下。我正在使用jjpfin的教程,这是近3年前制作的。 The Tutorial
非常感谢提前。
答案 0 :(得分:1)
您的JSON无效,因为您缺少]
个字符。替换此行
[[{"name":"TEMP"},{"gpio":"4"},{"sensorType":"22"},{"temperatureLowLimit":"0"},{"temperatureHighLimit":"25"},{"temperatureThreshold":"5"},{"humidityLowLimit":"30"},{"humidityHighLimit":"60"},{"humidityThreshold":"10"}],
用这个
[[{"name":"TEMP"},{"gpio":"4"},{"sensorType":"22"},{"temperatureLowLimit":"0"},{"temperatureHighLimit":"25"},{"temperatureThreshold":"5"},{"humidityLowLimit":"30"},{"humidityHighLimit":"60"},{"humidityThreshold":"10"}]],
未来的有用工具,以及我用来检查问题的工具是JSONlint。