Does writing JSON in a single line create any problem?
Question:
I have used json.dump() without indent
with open (JSONfilename, 'w', encoding='utf-8') as f:
json.dump(data, f, ensure_ascii=False)
f.close()
This saves all of JSON data in a single line. I have done this because I noticed that using indent=4 for formatting JSON file increases it size. Is saving big JSON file in single line ok or will I encounter any problem in future?
Edit: Does it effect on saving, loading or parsing time?
Answers:
Well, people will have trouble reading it, if you consider that a problem.
The JSON parser ignores whitespace outside of quotation marks.
The format of .json file will be okay.
I want to add one ‘Important@ thing. While reading the same file, json.load module only can read till 226538 column length in one line. If you data is much larger, It will cause this extra data problem in one line.
I have used json.dump() without indent
with open (JSONfilename, 'w', encoding='utf-8') as f:
json.dump(data, f, ensure_ascii=False)
f.close()
This saves all of JSON data in a single line. I have done this because I noticed that using indent=4 for formatting JSON file increases it size. Is saving big JSON file in single line ok or will I encounter any problem in future?
Edit: Does it effect on saving, loading or parsing time?
Well, people will have trouble reading it, if you consider that a problem.
The JSON parser ignores whitespace outside of quotation marks.
The format of .json file will be okay.
I want to add one ‘Important@ thing. While reading the same file, json.load module only can read till 226538 column length in one line. If you data is much larger, It will cause this extra data problem in one line.