Adding metadata to json
Better error message