[ad_1]
when I use Json to edit json files, how can I make the dump indent only strings not arrays.
here is my original json file,original.
I want to edit the “user_id_list”, so I did
import json
uid=5632914777
with open("config.json", "r+") as jsonFile:
data = json.load(jsonFile)
data["user_id_list"] = uid
jsonFile.seek(0)
json.dump(data, jsonFile,indent=4)
jsonFile.truncate()
and the result looks like this:indented. Clearly, the array in brackets is indented too.
I want to make the format just like the original file, and only the “user_id_list” changed. How can I do that?
[ad_2]