Filemeta json v2

Fixed som bugs in my former pull request, shortend the code abit. Tested the output to be json format validated.