JSON output for other directories fixes
Fix output if directory is given
Fix output when refering to other directories or links

(For XML too)