Changing doc to valid json format