Slightly safer JSON reading

Close the file handle before we do anything to the read data.