1

I try to save my data (type list of dictionaries) in a json file but this error was raised.

for i in range(0,len(data_sentences)):
    data_dic = {}
    data_dic["sentence"] = data_sentences[i]
    data_dic["aspect"] = data_attributes[i]
    data_dic["polarity"] = data_sentiments[i]
    data.append(data_dic)


with open(jsonname+'.json', 'w') as outfile:
    json.dump(data, outfile) 

The error was like:

TypeError: Object of type 'time' is not JSON serializable

But weirdly the json file was generated correctly. After Googleing I only found solutions to datatime which seems irrelevant.

Any tips will be appreciated!

Yingqiang Gao
  • 939
  • 4
  • 16
  • 29
  • 1
    I didn't use any time modules I just packed the data into a list. I don't know why it has something to do with the time – Yingqiang Gao Jun 18 '18 at 08:17

0 Answers0