move file stuff out of json

Json code should not be dealing with files.

This is refactoring only, no behavior changes. However, it exposes a problem where output files for json files are calculated differently than for ddoc, di, and obj files. They should all be harmonized, but that is a topic for another pull.