Refactored and fixed from_json_stat() and implemented first version of to_json_stat()