Add main class and the to_json method