I want to write to the file structure:
class MyData(object): def __init__(self): self.m_nID = 0 self.m_strTitle = "" def serialize(self): temp_dict = { 'ID': self.m_nID, 'Title': self.m_strTitle} return temp_dict def setData2File(a_data, a_str_path): file = open(a_str_path, "w") json.dump(a_data, file, ensure_ascii=False, indent=4) if __name__ == '__main__': # ... work ... work ... work for result in arrResults: FileUtils.setData2File(result.serialize() , "test.json") Everything is perfectly recorded in the file, BUT: for some reason with formatting, i.e. "{\" Title \ ": \" Pythons — Wikipedia \ ", \" ID \ ": 1}"
I have been suffering for a long time and can’t understand what the problem is, how can I deduce a pretty version without a slash and other extra characters?
open(a_str_path, 'w')- gil9redresultfromFileUtils.setData2File(result.serialize() , "test.json")? - MaxU