Write custom to_json method, now need to fix tests.