I have a JSON file that looks like this:
{"environment": "production",
"classes":
{"nfs::server": {"exports": ["/srv/share1","/srv/share3"]}}
}
When I run the following code using Python 3.6
fp=open('example.json', 'r')
data=json.load(fp)
print(50*'-')
print(json.dumps(data, indent=4))
print(50*'-')
json.dump(data, sys.stdout, indent=4)
I get the output:
--------------------------------------------------
{
"environment": "production",
"classes": {
"nfs::server": {
"exports": [
"/srv/share1",
"/srv/share3"
]
}
}
}
--------------------------------------------------
{
"environment": "production",
"classes": {
"nfs::server": {
"exports": [
"/srv/share1",
"/srv/share3"
]
}
}
}%
My question is why is the extra % included in the json.dump output compared to the json.dumps string? It is not an artifact of the OS because if I provide a file object instead of sys.stdout it also gets written to the file.
zsh, not usingbash