CloudFoundry: CLI error, unexpected end of JSON input

If you receive this error upon trying to run commands from the CloudFoundry CLI:

"Error read/writing config: unexpected end of JSON input"

This is most likely due to an error in the “$HOME/.cf/config.json” file.  Make sure the user has full ownership:

ls -l ~/.cf/config.json
chown $USER:$USER ~/.cf/config.json
chmod 755 ~/.cf/config.json

And if that does not resolve the issue, then set the file contents to an empty json string:

cp ~/.cf/config.json ~/.cf/config.json.bak
echo "{}" > ~/.cf/config.json

REFERENCES

Bug report 1027

Bug report 1071