简体   繁体   中英

How to write JSON to file with null values in python?

{"1":null, "2":false, "3":true}

I don't need them to be converted to None False True.

According to this page https://www.w3schools.com/python/python_json.asp

The python None Type is converted to null that you're looking for

Python JSON
dict Object
list Array
tuple Array
str String
int Number
float Number
True true
False false
None null
with open(r"D:\microsoft presentation\json.json", 'w+') as outfile:
     json.dump(output, outfile, sort_keys = False, indent = 4, ensure_ascii = False)

https://stackoverflow.com/a/20776329/13226851

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM